python爬取图片失败显示404_使用Python的Web爬网给出HTTP错误404:找不到

新手使用Python进行Web爬虫时,在尝试从Transfermarkt网站抓取足球数据时遇到了HTTP 404错误。问题出在用户代理可能被服务器拒绝。解决方案是设置请求头,模拟浏览器访问,避免被识别为爬虫。
摘要由CSDN通过智能技术生成

I am brand new to Python and have not very good at it. I am trying to web scrape from a website called Transfermarkt (I'm a big football fan) but its giving me HTTP Error 404 when I try extract data. Here is my code:

from urllib.request import urlopen as uReq

from bs4 import BeautifulSoup as soup

my_url = "https://www.transfermarkt.com/chelsea-fc/leihspielerhistorie/verein/631/plus/1?saison_id=2018&leihe=ist"

uClient = uReq(my_url)

page_html = uClient.read()

uClient.close()

page_soup = soup(page_html, "html.parser")

for che in chelsea:

player = che.tbody.tr.td.table.tbody.tr.td["spielprofil_tooltip tooltipstered"]

print("player: " +player)

Error says:

Traceback (most recent call last):

File "C:\Users\x15476582\Deskto

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值