ScrapeNinja

GRATIS CON POSSIBILITÀ DI UPGRADE
Da Anthony | Aggiornamento il y a 23 jours | Data
Popolarità

9.9 / 10

Latenza

3,742ms

Livello di servizio

97%

Health Check

N/A

Torna a tutte le discussioni

escape character, source code backslashed

Rapid account: Alvro Lopez
AlvroLopez
il y a 2 ans

Every time I make a ScrapeNinja request I get a “backslashed” response, a response having \ behind every quotation mark and behind any other backslash. This makes it tricky for parsing as, say, Scrapy selectors won’t find the right attributes and adding backslashes won’t fix anything: Python will read backslash as an escape character, not as a regular character. Adding two backslashes doesn’t work and using regex (which also uses \ as an escape character) is a mess since you can easily have 5 backslashes for just a newline. A brief example I just got from an e-commerce web:

<a class=“LEVEL_3” id=“Nav_W1101_0” href="/compra-online/bebidas/agua-soda-y-gaseosas/c/W1101" title=“Agua, Soda y Gaseosas”>Agua, Soda y Gaseosas</a>\n<ul class=“LEVEL_3”>\n</ul>\n</div>\n

Is there any way I can get the right source code? str.replace("", “”) usually destroys useful information

Rapid account: Restyler
restyler Commented il y a 2 ans

Hi!
I think now we are also dealing with RapidAPI text formatting and escaping 😃
ScrapeNinja serializes the request to JSON, so it needs to escape certain characters, but when you parse this JSON, the HTML should be back to its original form… are you saying that you have issues with escaping AFTER you already have parsed the returned JSON object and retrieved the .body property of the ScrapeNinja response?

https://youtu.be/UHOY-LubMsM?t=210

Partecipa alla discussione - aggiungi un commento di seguito:

Accedi/Iscriviti per pubblicare nuovi commenti