我目前正试图网络刮蒸汽商店销售网页,但我可以刮所有的名称和折扣,但我不知道如何从数据中删除标签
我的代码是:
import bs4 as bs
import urllib.request
#opening a connection
my_url = urllib.request.urlopen('https://store.steampowered.com/search/?specials=1&os=win').read()
#turning the html into a beautifulsoup object
soup = bs.BeautifulSoup(my_url, 'lxml')
def remove_tags(text):
return ''.join(xml.etree.ElementTree.fromstring(text).itertext())
data_discounts = (soup.find_all('div', {'class':'col search_discount responsive_secondrow'}))
data_body = (soup.find_all('span', {'class':'title'}))
print (data_body)
试试这个:
相关问题 更多 >
编程相关推荐