Web Scraping in Python

def get_data(url, title_selector)
response = requests.get(url)
if status_code == 200
content = str(response.content, ‘utf-8’)
tree = html.fromstring(content)
titles = tree.cssselect(title_selector)
for title in titles:
print(title.text_content())
get_data(
'https://www.python.org',
'div.event-widget > div.shrubbery > ul.menu > li > a'
)
‘div.event-widget > div.shrubbery > ul.menu > li > a’

--

--

--

Someone who likes dancing with codes. github.com/gorkemunuvar

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Tableau CRM Salesforce Output connectors

Unsupervised Text Classification in PowerShell :Part 1

5 Tips To Deal With Untested Code

Linux Centos 7磁碟掛載新空間並給mariadb使用

Take screenshot of entire webpage easily in Google Chrome without installing any extension.

Tutturu says hi

Real-time screen of playing video on Tutturu with text and voice chat

Some Useful Commands — Linux, Python, Pip

Data Engineering Explained: Data Serialization, backward and forward compatibility

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Görkem

Görkem

Someone who likes dancing with codes. github.com/gorkemunuvar

More from Medium

Web Scraping Using Scrapy and Regular Expressions in Python

1-Introduction to Python

Scrapy Tutorial — Part 4

Web scraping with Python, Selenium and Pandas