Skip to content

Instantly share code, notes, and snippets.

@moonzlo
Created June 1, 2019 21:55
Show Gist options
  • Select an option

  • Save moonzlo/9aed0eaa57474e66dbb447bd3a80424d to your computer and use it in GitHub Desktop.

Select an option

Save moonzlo/9aed0eaa57474e66dbb447bd3a80424d to your computer and use it in GitHub Desktop.
lxml example
tree = etree.HTML(html)
for block in tree.xpath("//div[@class='product']"):
img = block.xpath("//img/@src")[0]
name = block.xpath("//tr[@class='name']")[0].text
id = block.xpath("//tr[@class='id']")[0].text
@moonzlo
Copy link
Author

moonzlo commented Jun 1, 2019

Аналогичен
soup = BeautifulSoup(page) # page - скачиваем страницу и отдаем ее
for item in soup.findAll("div", {"class": "product"}):
img = item.find("img")["src"]
name = soup.find("tr", {"class": "name"})
id = soup.find("tr", {"class": "id"})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment