想写个爬虫,爬到 form,填表,提交,然而目标站有保护,求助! - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
way2explore2
V2EX    Python

想写个爬虫,爬到 form,填表,提交,然而目标站有保护,求助!

  •  
  •   way2explore2 2017-06-19 16:09:00 +08:00 3726 次点击
    这是一个创建于 3035 天前的主题,其中的信息可能已经有所发展或是发生改变。

    直接不隐讳的直接说了,想写个 python 脚本帮朋友申请签证名额,

    遇到的问题

    1. 每次 get,得到的都是 noscript 的提示,需要 JS
    2. 对于非本地 IP 有验证码

    我的尝试

    mechanize

    import sys import mechanize url ='xxx' response2=br.open(url) request = br.request print (response2.info()) print (response2.read()) 

    output:

    Cache-Control: no-store, must-revalidate, no-cache, max-age=0 Content-Type: text/html Connection: close Vary: Accept-Encoding Pragma: no-cache Expires: -1 CacheControl: no-cache X-UA-Compatible: IE=edge Content-Type: text/html; charset= ... more content ... <noscript>Please enable Javascript to view the page content.</noscript> </head><body> </body></html> 

    selenium

    from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.Firefox() url= 'xxx' driver.get(url) print driver.context print driver.title print driver.page_source driver.close() 

    output

    nosctipt 同上 

    Refes

    1. 目标站点及详细问题,请见 so https://stackoverflow.com/questions/44562212/fetching-web-page-but-need-Javascript-to-view-page-content
    2. 目标 url 在 comment 里
    12 条回复    2023-05-18 15:03:35 +08:00
    golmic
        1
    golmic  
       2017-06-19 16:14:46 +08:00
    怎么登录,需要用户名密码啊。可以帮你看看
    chuanqirenwu
        2
    chuanqirenwu  
       2017-06-19 16:54:19 +08:00
    直接开 selenium 在真机上刷,以前刷论坛是这么做的。
    LeeSeoung
        3
    LeeSeoung  
       2017-06-19 17:02:08 +08:00
    1、需要 JS 要么协议头有问题,要么获取了 cookies,要处理。
    2、对接验证码平台。
    XiaoFaye
        4
    XiaoFaye  
       2017-06-19 17:03:32 +08:00
    楼主,是新西兰的 WHV 签证吧?别爬了,没用的。这个现在只能靠手速和自动填表了。23 号就开抢了,你现在准备也太晚了吧?今年网站已经改版了,表格最新的 DOM 信息有吗?付款页面的 DOM 信息有吗?这些我都有,不过一早已经没兴趣抢了。不过移民政策改了,相信今年抢的人不会那么多了,君不见淘宝的代抢价格已经从 7000 多降到 4000 多了吗?

    最后,祝你朋友好运啦!
    bget
        5
    bget  
       2017-06-20 07:10:10 +08:00
    推荐个爬虫软件你试一下:www.sensite.cn/bget,支持 JS 解析,扩展性强,支持可视化配置。
    prasanta
        6
    prasanta  
       2017-06-21 14:39:44 +08:00 via Android
    你还不如写一个 chrome 插件,自动填表
    way2explore2
        7
    way2explore2  
    OP
       2017-06-21 15:59:26 +08:00
    @XiaoFaye 这对朋友不是中国的,开抢事件不一样
    way2explore2
        8
    way2explore2  
    OP
       2017-06-21 16:00:44 +08:00
    @bget 不是我不想用,只是这 UI 和网站为什么有点很老旧的感觉。
    ![img]( http://www.sensite.cn/images/BgetMainWindow.gif)
    way2explore2
        9
    way2explore2  
    OP
       2017-06-21 16:01:44 +08:00
    @XiaoFaye 另外,Dom 真的不是问题,你看一眼他的 form 你就知道了
    way2explore2
        10
    way2explore2  
    OP
       2017-06-21 16:04:18 +08:00
    @golmic 多谢,我之前申请了一个测试用的账号
    email
    [email protected]
    pwd:
    ieJai3Yae
    way2explore2
        11
    way2explore2  
    OP
       2017-06-21 16:05:14 +08:00
    @chuanqirenwu 我试了 selenium,你说的真机上刷,是指?
    MatrixMan
        12
    MatrixMan  
       2023-05-18 15:03:35 +08:00
    老哥有成功过吗?我最近想研究一下,搞一下这个
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     1351 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 21ms UTC 23:59 PVG 07:59 LAX 16:59 JFK 19:59
    Do have faith in what you're doing.
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86