【回帖鱼币】爬虫地址访问403原因或出现请开启JavaScript并刷新该页
想做一个吾爱签到的脚本,以下是参考资料,我替换了自己的cookie后出现了403更换过ip后仍然是403 ,开始时直接用浏览器访问能正常访问时,程序访问已出现403。然后找了资料删除部分无效cookie值,但是又出现“请开启JavaScript并刷新该页”,求指导
# -*- coding: utf8 -*-
#git原地址:https://github.com/sanshuifeibing/ExampleForSCF
import requests
from bs4 import BeautifulSoup
def main(*args):
headers={
'Cookie': '(想啥呢,cookie怎么能告诉你呢,要不不就完了?)' ,
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36'
}
a=requests.session().get('https://www.52pojie.cn/home.php?mod=task&do=draw&id=2',headers=headers)
b=BeautifulSoup(a.text,'html.parser')
c=b.find('div',id='messagetext').find('p').text
if "您需要先登录才能继续本操作"in c:
print("Cookie失效", c)
elif "恭喜"in c:
print("吾爱破解签到成功",c)
elif "任务"in c:
print("今日已经手动签到",c)
else:
print("吾爱破解签到失败",c)
print(c)
if __name__ == '__main__':
main() 本帖最后由 xiaosi4081 于 2022-1-9 09:21 编辑
直接换个selenium不香?
but,这个是需要浏览器驱动的,所以去装一个吧
网址:
chrome的webdriver: http://chromedriver.storage.googleapis.com/index.html
Firefox驱动下载地址为:https://github.com/mozilla/geckodriver/releases/
IE浏览器驱动下载地址为:http://selenium-release.storage.googleapis.com/index.html
根据自己浏览器的版本下载
下完放到浏览器根目录和python根目录
在cmd运行:
pip install selenium
我做过一个鱼C发帖的:
https://fishc.com.cn/forum.php?mod=viewthread&tid=171447 如果你想用selenium:https://fishc.com.cn/forum.php?mod=viewthread&tid=144436&highlight=%D3%E3C%D7%D4%B6%AF%C7%A9%B5%BD
这个是用于BBS的,吾爱应该也是这个
这个是用cookie的:https://fishc.com.cn/forum.php?mod=viewthread&tid=168499&highlight=%D3%E3C%D7%D4%B6%AF%C7%A9%B5%BD
只要稍加改动就可以了
关于403的话,https://blog.csdn.net/u011808673/article/details/80609221 {:10_279:} {:10_258:} {:10_254:} xiaosi4081 发表于 2022-1-9 09:26
如果你想用selenium:https://fishc.com.cn/forum.php?mod=viewthread&tid=144436&highlight=%D3%E3C%D7%D4% ...
不想用这个,想挂平台用的 tianlai7266 发表于 2022-1-9 19:28
{:10_256:} {:10_254:} {:10_256:} {:10_254:} 好耶 {:9_241:} {:10_254:} {:5_109:} 厉害!! 厉害 {:10_254:} {:10_254:} {:10_280:}
页:
[1]
2