Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用requests可以正常请求,使用feapder提示浏览器版本过低,有点搞不懂 #129

Closed
lscool66 opened this issue Nov 8, 2021 · 6 comments

Comments

@lscool66
Copy link

lscool66 commented Nov 8, 2021

import feapder

class CantonfairAirSpider(feapder.AirSpider):
def start_requests(self):
yield feapder.Request("https://www.cantonfair.org.cn",verify=True)

def parse(self, request, response):
    html = response.text
    print(html)

if name == "main":
CantonfairAirSpider().start()

@Boris-code
Copy link
Owner

贴下日志,可能是你urllib3版本低

@lscool66
Copy link
Author

贴下日志,可能是你urllib3版本低

C:\Users\lscoo\AppData\Local\Programs\Python\Python38\python.exe D:/projects/test/feapder-spiders/spiders/cantonfair_air_spider.py
当前工作路径为 D:\projects\test\feapder-spiders\spiders
<Request https://www.cantonfair.org.cn>

<title>浏览器版本过低</title> <style> .switch-browser { min-height: unset; height: 100vh; background: #fff; color: #333; display: flex; justify-content: center; align-items: center; }
  .switch-browser .switch-browser-tips {
    display: flex;
    align-items: center;
  }

  .switch-browser .switch-browser-tips .info-box .tit {
    font-size: 48px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    line-height: 67px;
    margin-bottom: 15px;
  }

  .switch-browser .switch-browser-tips .info-box .info {
    width: 352px;
    font-size: 18px;
    font-family: PingFangSC-Regular, PingFang SC;
    line-height: 25px;
    color: #666;
    margin-bottom: 24px;
  }

  .switch-browser .switch-browser-tips .info-box .browser-list {
    width: 397px;
    display: flex;
    flex-wrap: wrap;
  }

  .switch-browser .switch-browser-tips .info-box .browser-list .items {
    display: flex;
    padding: 8px 12px;
    box-sizing: border-box;
    height: 40px;
    border: 1px solid #dddddd;
    white-space: nowrap;
    text-decoration: none;
  }

  .switch-browser
    .switch-browser-tips
    .info-box
    .browser-list
    .items:hover {
    border-color: #bbb;
  }

  .switch-browser
    .switch-browser-tips
    .info-box
    .browser-list
    .items
    + .items {
    margin-left: 8px;
  }

  .switch-browser
    .switch-browser-tips
    .info-box
    .browser-list
    .items
    .icon {
    display: block;
    width: 24px;
    height: 24px;
    margin-right: 4px;
  }

  .switch-browser
    .switch-browser-tips
    .info-box
    .browser-list
    .items
    .tips {
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC;
    line-height: 20px;
    color: #666;
  }

  .switch-browser
    .switch-browser-tips
    .info-box
    .browser-list
    .items:nth-of-type(1)
    .icon {
    background: url(//cdn.cantonfair.org.cn/static/v05221938/img/google.png)
      no-repeat;
    background-size: cover;
  }

  .switch-browser
    .switch-browser-tips
    .info-box
    .browser-list
    .items:nth-of-type(2)
    .icon {
    background: url(//cdn.cantonfair.org.cn/static/v05221938/img/ie.png)
      no-repeat;
    background-size: cover;
  }

  .switch-browser
    .switch-browser-tips
    .info-box
    .browser-list
    .items:nth-of-type(3)
    .icon {
    background: url(//cdn.cantonfair.org.cn/static/v05221938/img/qq.png)
      no-repeat;
    background-size: cover;
  }

  .switch-browser .switch-browser-tips .pic {
    margin-left: 27px;
    width: 320px;
    height: 320px;
    background: url(//cdn.cantonfair.org.cn/static/v05221938/img/bad-browser.png)
      no-repeat;
    background-size: cover;
  }
</style>
<link
  rel="shortcut icon"
  href="https://cdn.cantonfair.org.cn/static/favicon.ico"
/>
浏览器版本过低
请切换或升级浏览器,以获得更安全环境及更佳体验。

2021-11-18 11:22:52.155 | INFO | feapder.core.spiders.air_spider:run:104 - 无任务,爬虫结束

进程已结束,退出代码为 0

@lscool66
Copy link
Author

C:\Users\lscoo\AppData\Local\Programs\Python\Python38\python.exe D:/projects/test/feapder-spiders/spiders/cantonfair_air_spider.py
当前工作路径为 D:\projects\test\feapder-spiders\spiders
C:\Users\lscoo\AppData\Local\Programs\Python\Python38\lib\site-packages\requests_init_.py:89: RequestsDependencyWarning: urllib3 (1.26.7) or chardet (3.0.4) doesn't match a supported version!
warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
<Request https://www.cantonfair.org.cn>

<title>浏览器版本过低</title> <style> .switch-browser { min-height: unset; height: 100vh; background: #fff; color: #333; display: flex; justify-content: center; align-items: center; }
  .switch-browser .switch-browser-tips {
    display: flex;
    align-items: center;
  }

  .switch-browser .switch-browser-tips .info-box .tit {
    font-size: 48px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    line-height: 67px;
    margin-bottom: 15px;
  }

  .switch-browser .switch-browser-tips .info-box .info {
    width: 352px;
    font-size: 18px;
    font-family: PingFangSC-Regular, PingFang SC;
    line-height: 25px;
    color: #666;
    margin-bottom: 24px;
  }

  .switch-browser .switch-browser-tips .info-box .browser-list {
    width: 397px;
    display: flex;
    flex-wrap: wrap;
  }

  .switch-browser .switch-browser-tips .info-box .browser-list .items {
    display: flex;
    padding: 8px 12px;
    box-sizing: border-box;
    height: 40px;
    border: 1px solid #dddddd;
    white-space: nowrap;
    text-decoration: none;
  }

  .switch-browser
    .switch-browser-tips
    .info-box
    .browser-list
    .items:hover {
    border-color: #bbb;
  }

  .switch-browser
    .switch-browser-tips
    .info-box
    .browser-list
    .items
    + .items {
    margin-left: 8px;
  }

  .switch-browser
    .switch-browser-tips
    .info-box
    .browser-list
    .items
    .icon {
    display: block;
    width: 24px;
    height: 24px;
    margin-right: 4px;
  }

  .switch-browser
    .switch-browser-tips
    .info-box
    .browser-list
    .items
    .tips {
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC;
    line-height: 20px;
    color: #666;
  }

  .switch-browser
    .switch-browser-tips
    .info-box
    .browser-list
    .items:nth-of-type(1)
    .icon {
    background: url(//cdn.cantonfair.org.cn/static/v05221938/img/google.png)
      no-repeat;
    background-size: cover;
  }

  .switch-browser
    .switch-browser-tips
    .info-box
    .browser-list
    .items:nth-of-type(2)
    .icon {
    background: url(//cdn.cantonfair.org.cn/static/v05221938/img/ie.png)
      no-repeat;
    background-size: cover;
  }

  .switch-browser
    .switch-browser-tips
    .info-box
    .browser-list
    .items:nth-of-type(3)
    .icon {
    background: url(//cdn.cantonfair.org.cn/static/v05221938/img/qq.png)
      no-repeat;
    background-size: cover;
  }

  .switch-browser .switch-browser-tips .pic {
    margin-left: 27px;
    width: 320px;
    height: 320px;
    background: url(//cdn.cantonfair.org.cn/static/v05221938/img/bad-browser.png)
      no-repeat;
    background-size: cover;
  }
</style>
<link
  rel="shortcut icon"
  href="https://cdn.cantonfair.org.cn/static/favicon.ico"
/>
浏览器版本过低
请切换或升级浏览器,以获得更安全环境及更佳体验。

2021-11-18 11:25:33.096 | INFO | feapder.core.spiders.air_spider:run:104 - 无任务,爬虫结束

进程已结束,退出代码为 0

@kk-deng
Copy link

kk-deng commented Dec 1, 2021

我发现随机UA有时候的chrome header版本号是23这种低版本的,现在都96了。不知道是不是这原因导致,如果能给一个随机UA是高版本号的选择就好了

@lscool66
Copy link
Author

lscool66 commented Dec 1, 2021

我发现随机UA有时候的chrome header版本号是23这种低版本的,现在都96了。不知道是不是这原因导致,如果能给一个随机UA是高版本号的选择就好了

还真是这样,关闭随机ua就好了

@lscool66 lscool66 closed this as completed Dec 1, 2021
@kk-deng
Copy link

kk-deng commented Dec 1, 2021

我发现随机UA有时候的chrome header版本号是23这种低版本的,现在都96了。不知道是不是这原因导致,如果能给一个随机UA是高版本号的选择就好了

还真是这样,关闭随机ua就好了

刚看了里面的随机 user_agent.py pool,发现这文件内容是2016年的,所以这pool里面的UA都太老了。遇到一些检查UA的网站估计就像你遇到的情况一样。如果作者没空更新的话,我可以去搜集一些最新的提交PR。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants