Home > Back-end >  How to extract a text from ng-herf with scrapy
How to extract a text from ng-herf with scrapy

Time:07-19

There is a real state website with an infinite scroll down and I have tried to extract the companies' names and other details but I have a problem with writing the selectors need some insights for a new learner in scrapy.
HTML Snippet:
inspect code image

CodePudding user response:

After handling if "more" button is available in website.
So, the selector appears in most browsers you can copy selectors like this this an example

based on the function you are using you copy "xpath" or something else for scrapping process,

If that's does not help please give the link to webpage and select what values you want to scrap.

CodePudding user response:

As I understand, you want to get the href from the tag and you don't know how to do it in scrapy. you just need to add ::attr(ng-href) this to the last of your CSS selectors.

link = response.css('your_selector::attr(ng-href)').get()

to make it easier for you your CSS selector should be

link = response.css('.companyNameSpecs a::attr(ng-href)').get()

but it looks like the href and ng-href is the same you can also do the same with it

link = response.css('your_selector::attr(href)').get()
  • Related