Python Web Scraping | BeautifulSoup with XPATH

Veröffentlicht am: 03 Mai 2021
auf dem Kanal: jobstr
7,096
94

If you have been told that you can't use XPATH selectors with BeautifulSoup and Python....Well..You can.
You can use lxml with requests without using BeautifulSoup.
If you need to use BeautifulSoup (bs4) for parsing certain parts of the target page then you can write you code as per this video and use XPATH selectors should you need to (or want to).

I demonstrate how to use xpath selectors when scraping news articles and then display them in terminal shell.

I've used Linux and Vim, but this will work equally well with Windows, Mac, and whatever editor you choose.Use these imports and you will be able to copy my code.

You need to do "pip install package-name" if you get a message saying 'module not found'.

import requests
from bs4 import BeautifulSoup
from lxml import etree

🔥🔥🔥 Proxies
🌏 10% off ScraperAPI : https://www.scraperapi.com?fpr=ken49
◼️ Coupon Code: DRPI10
(You can also get started with 1000 free API calls. No credit card required.)

Buy Dr Pi a coffee (or Tea)
☕ https://www.buymeacoffee.com/DrPi

Proxies
=================================================
If you need a good, easy to use proxy, I was recommended this one, and having used ScraperAPI for a while I can vouch for them. If you were going to sign up anyway, then maybe you would be kind enough to use the link and the coupon code below?

You can also do a full working trial first as well, (unlike some other companies). The trial doesn't ask for any payment details either so all good! 👍

Thumbs up yeah? (cos Algos..)

#webscraping #tutorials #python


Auf dieser Seite können Sie das Online-Video Python Web Scraping | BeautifulSoup with XPATH mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer jobstr 03 Mai 2021 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 7,096 Mal angesehen und es wurde von 94 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!