search

Home  >  Q&A  >  body text

python - 爬虫如何获取onclick的链接

<a onclick="xxx(1)">xxxx</a>

类似如上这种需要点击一下才会打开一个网页的,这种链接该如何获取呢?
除了手工分析参数自己构造请求, selenium 定位模拟点击,还有什么方法么?

大家讲道理大家讲道理2866 days ago1688

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-04-18 10:25:14

    If the js is obfuscated or encrypted and the link cannot be obtained directly from the code, then only simulated clicks can be done.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 10:25:14

    from bs4 import BeautifulSoup as bs
    
    for a_tag in  bs(html_body,'html.parser').find_all('a'):
        print(a_tag['onclick'])

    reply
    0
  • 阿神

    阿神2017-04-18 10:25:14

    Regular expression extraction

    reply
    0
  • Cancelreply