Python中文
首页
教程
问答
标签
搜索
登录
注册
Python requests.get仅在未指定页码时响应
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我正在使用python使用请求和BeautifulSoup抓取web数据。我发现,我正在抓取的两个网站只有在我没有指定页码的情况下才会回复</p> <p>以下代码起作用,允许我提取所需的数据:</p> <pre><code>headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)} r = requests.get('https://www.milkround.com/jobs/graduate-software-engineer', headers = headers) soup = BeautifulSoup(r.content, 'html5lib') table = soup.find('div', attrs = {'class':'col-xs-12 job-results clearfix'}) </code></pre> <p>但是,如果我更改链接以指定页码,例如:</p> <pre><code>r = requests.get('https://www.milkround.com/jobs/graduate-software-engineer?page=2', headers = headers) </code></pre> <p>然后请求永远不会响应。没有错误代码,控制台只是无限期地等待。这是什么原因造成的?如何解决</p> <p>编辑:我以匿名方式手动打开了该网站。似乎当用页码打开时,我会得到一个“拒绝访问”的响应,但是如果我刷新页面,它会允许我进入吗</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>这是因为如果你看到了,你就无法从外部访问网站上的页码。因此,如果您已登录并拥有某种cookie,则将其添加到您的标题中</p> <p>我刚才在网站上查到的是你们试图访问错误的URI。并没有页码。您是否添加了自己的<strong>?页面=</strong></p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何添加虚拟方法
9 回答
如何添加表示整数的擦边字符串?
2 回答
如何添加要在Bokeh中使用的新font.ttf文件?
1 回答
如何添加要显示的矩阵XY轴编号和XY轴
1 回答
如何添加计数?
6 回答
如何添加计数器函数?
6 回答
如何添加计数器列来计算数据帧中另一列中的特定值?
2 回答
如何添加计数器来跟踪while循环中的月份和年份?
5 回答
如何添加计数并删除countplot的顶部和右侧脊椎?
1 回答
如何添加计时器wx.应用程序更新窗口对象的主循环?
10 回答
如何添加评论到帖子?PostDetailVew,Django 2.1.5
2 回答
如何添加评论拉梅尔亚姆
9 回答
如何添加诸如矩阵Python/Pandas之类的数据帧?
10 回答
如何添加谷歌地点自动完成到Flask?
3 回答
如何添加超时、python discord bot
9 回答
如何添加超过1dp的检查
5 回答
如何添加距离方法
3 回答
如何添加跟随游戏的敌人精灵
1 回答
如何添加路径以便python可以找到程序?
6 回答
如何添加身份验证/安全性以使用happybase访问HBase?
5 回答