好友
阅读权限 10
听众
最后登录 1970-1-1
#_*_ coding="UFT-8" _*_
import os,sys,time
import requests
from bs4 import BeautifulSoup
import re
#______________________________________
def download(html:str):
rr=requests.get(html)
soup2=BeautifulSoup(rr.text,'html.parser')
gamedownload={}
for dl in soup2.find_all('a',class_="omsc-button omsc-no-custom-hover omsc-size-medium omsc-with-icon omsc-style-flat omsc-text-bright"):
print(dl.get('href'))
#---------------------------------------
def main():
url="https://truckgame.cn/game"
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36'}
r=requests.get(url,headers=headers)
soup=BeautifulSoup(r.text,'html.parser')
game={}
dizhi=[]
for s in soup.find_all('div',class_="row postLists lists"):
for j in s.find_all('div',{"class":"col-xxs-6 col-xs-4 col-sm-6 col-md-4 col-lg-3 post-card-wrapper"}):
game={
'游戏名':j.find('h2').string,
'链接':download(str(j.find('a',class_="cover").get('href')))
}
print(game)
if __name__ == '__main__':
main()
上面的结果 居然游戏地址在上面,反而字典里的链接是NONE值 奇怪了 ,这是哪里不对啊!!!为什么!!
发帖前要善用【论坛搜索 】 功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。