Web Scraping Yellow Pages with Python | Subscriber request using Scrapy and Xpath

Publicado em: 01 Janeiro 1970
no canal de: jobstr
724
12

Scraping Yellow Pages.
A demonstration of finding selectors in Chrome, testing them in the browser developer tools, and then making Scrapy iterate through using accurate and not so accurate selectors.
The main focus of this video is on refining the xpath in the browser developer tools before pasting into your Scrapy spider code.



The full code is here on my GitHub page : https://github.com/RGGH/Scrapy9



: Chapter timings : -


0:00 Introduction - what are we scraping? Why?
0:32 The spider code so far
0:55 The parse method
1:43 Ctrl + F in Chrome
2:57 xpaths : using predicates
4:15 Using "*" wildcard versus "p" or "div" or "span" element
8:22 Finding website addresses
9:55 xpath using 2 predicates
11:28 Updating the Scrapy spider code...adding the selector for 'website'
13:40 Test
14:15 Troubleshooting
14:46 Quick change of selector for website! - No need for 2 predicates!
15:07 Running the spider
15:25 The "."
16:55 Success
17:55 Summary
20:25 Closing comments


If you want more info relating to xpaths, here are some examples plus a great site to check out:

⦿ response.xpath("//div[@class='article']//a/img/@src")
⦿ response.xpath('//a[contains(text(), "Next »")]/@href')
⦿ response.xpath('//div[@class='pibox']/descendant::*/text()')

https://devhints.io/xpath


contains is a really useful one, and it can future proof your spider, as even if the css changes, "Next" should still be spelled the same!


All the best,
Dr Pi.


Nesta página do site você pode assistir ao vídeo on-line Web Scraping Yellow Pages with Python | Subscriber request using Scrapy and Xpath duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário jobstr 01 Janeiro 1970, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 724 vezes e gostou 12 espectadores. Boa visualização!