1 回答
![?](http://img1.sycdn.imooc.com/533e4bd900011a1d02000200-100-100.jpg)
TA贡献1876条经验 获得超5个赞
使用zip()内置函数将数据“绑定”在一起:
import requests
from bs4 import BeautifulSoup
def makesoup(url):
cookies = {'mycountries' : '101,28,3,102,42,10,18,4,2'}
r = requests.post(url, cookies=cookies)
return BeautifulSoup(r.text,"lxml")
def matchscrape(g_data):
for match in g_data:
scheduled = match.findAll('div', class_='main time col-sm-2 hidden-xs')
details = match.findAll('div', class_='col-xs-6 mobile-normal')
for s, d in zip(scheduled, details): # <-- using zip() here!
print(s.text.strip())
print(d.text.strip())
def matches():
soup=makesoup(url = "https://sport-tv-guide.live/live/darts")
matchscrape(g_data = soup.findAll("div", {"class": "listData"}))
matches()
印刷:
Darts 17:00
Simon Whitlock vs. Joyce Ryan
World Matchplay
Darts 18:00
Ratajski Krzysztof vs. Wattimena Jermaine
World Matchplay
添加回答
举报