Answer the question
In order to leave comments, you need to log in
How to parse text from a given line?
def price_parse(links):
import requests
from lxml import etree
for url in links:
info = requests.get(url)
tree = etree.parse(info, etree.HTMLParser())
rarity = tree.xpath('.//*[@id="largeiteminfo_item_type"]')[0].text
print(rarity, url)
def price_parse(links):
import requests
from bs4 import BeautifulSoup
for url in links:
info = requests.get(url)
soup = BeautifulSoup(info.content, 'html.parser')
rarity = soup.find('div', id='largeiteminfo_item_type')
print(rarity, url)
<div id="largeiteminfo_item_type" class>Covert Pistol</div>
Answer the question
In order to leave comments, you need to log in
Something like this:
import io
import requests
from lxml import etree
for url in links:
info = requests.get(url)
tree = etree.parse(io.StringIO(info.text), etree.HTMLParser())
rarity = tree.xpath('.//*[@id="largeiteminfo_item_type"]')[0].text
print(rarity, url)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question