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
yellowtail
V2EX  ›  Python

第一次爬虫实战,在启信宝搜索结果的里使用检查元素,然后用 copy xpath 以后.click()用不了。。

  •  
  •   yellowtail · 2019-10-28 19:28:06 +08:00 · 3956 次点击
    这是一个创建于 1635 天前的主题,其中的信息可能已经有所发展或是发生改变。
    事业单位的小科员,正在帮同事填报 100 多家本地企业的类型,想用自动化解决,失败了。。
    yellowtail
        1
    yellowtail  
    OP
       2019-10-28 20:06:35 +08:00
    已 click
    yellowtail
        2
    yellowtail  
    OP
       2019-10-28 20:11:59 +08:00
    又不行了,正常工作了一次。。。又提示 Message: element click intercepted: Element <a href="/company/6819985a-9816-44a6-ba2d-42c9f3fd5b23" target="_blank" title="点击查看公司详情" data-event-search="1" keyid="6819985a-9816-44a6-ba2d-42c9f3fd5b23" queryid="ffb737c3-2a0f-4a26-a59d-a7f1a2a2710c">...</a> is not clickable at point (308, 669). Other element would receive the click: <p class="pull-left">...</p>
    (Session info: chrome=78.0.3904.70)
    yellowtail
        3
    yellowtail  
    OP
       2019-10-28 20:19:17 +08:00
    from selenium import webdriver
    import time

    driver = webdriver.Chrome(r'C:\Users\l\Downloads\chromedriver_win32\chromedriver')

    driver.get(r'https://www.qixin.com/?from=baidusem17')
    driver.find_element_by_xpath("/html/body/div[1]/div[2]/div/div[3]/div/div/div[2]/div/span[1]/input[2]").send_keys("岳阳临港高新技术产业发展有限公司")
    driver.find_element_by_xpath("/html/body/div[1]/div[2]/div/div[3]/div/div/div[2]/div/span[2]").click()
    time.sleep(5)

    driver.find_element_by_css_selector(
    "body > div.bg-b2.padding-b-50x > div.container.margin-t-0-6x >
    div > div.col-md-18 > div.padding-h-1x.border-h-b4.border-t-b4.app-list-items >
    div.row.bg-white > div:nth-child(1) > div.col-2.clearfix > div.col-2-1 >
    div.company-title.font-18.font-f1 > a"
    ).click()
    yellowtail
        4
    yellowtail  
    OP
       2019-10-28 20:19:46 +08:00
    嗨奥普。。
    Soar360
        5
    Soar360  
       2019-10-28 22:47:01 +08:00   ❤️ 1
    自嗨贴
    locoz
        6
    locoz  
       2019-10-28 23:29:18 +08:00 via Android   ❤️ 1
    …建议…用傻瓜式爬虫工具,别折腾了…
    tomczhen
        7
    tomczhen  
       2019-10-28 23:43:54 +08:00
    https://katalon.com

    轻量需求可以试试这种。
    jccg90
        8
    jccg90  
       2019-10-29 00:09:26 +08:00
    第一次就搞这种站。。。还是拿个简单的练手吧

    启信宝本身就是做爬虫的,肯定对于反爬很重视,你还爬他。。。
    ila
        9
    ila  
       2019-10-29 00:16:23 +08:00 via Android
    selenium,模拟点击
    tjx20114
        10
    tjx20114  
       2019-10-29 10:20:26 +08:00   ❤️ 1
    可以试下用 js 点击,上面报错是有东西挡住了这个 a 标签, js 点击没有遮挡的问题
    driver.execute_script('document.querySelector("css 选择器").click()')
    yellowtail
        11
    yellowtail  
    OP
       2019-10-29 18:31:13 +08:00
    @tjx20114 感谢,用 get_attribute("href")解决了,,再次感谢告知。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2892 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 262ms · UTC 02:45 · PVG 10:45 · LAX 19:45 · JFK 22:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.