D
D
dotruger372019-12-26 22:54:10
Python
dotruger37, 2019-12-26 22:54:10

How to parse words from a website in Python?

Hello. I have never parsed information from sites until now. There was a need to parse words from the site into an array (or into a file)
From here you need to parse -
study-english.info/vocabulary-american-slang.php
What should the Python code look like? (Preferably use XPath from lxml)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Yakushenko, 2019-12-27
@dotruger37

result = {}
for item in html.xpath('.//td/b/../following-sibling::td'):
    result[item.xpath('preceding-sibling::td')[0].text_content().strip()] = item.text_content().strip()

A
Andrey, 2019-12-26
@anerev

beautifulsoup

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question