【发布时间】:2023-03-26 15:50:01
【问题描述】:
我正在尝试从具有以下格式代码的 html 源中抓取验证码。
<div id="Custom"><!-- test: vdfnhu --></div>
验证码会随着每次刷新而改变。我的意图是捕获验证码及其验证代码,以便发布到表单。
到目前为止我的代码是:
import requests
import urlparse
import lxml.html
import sys
from bs4 import BeautifulSoup
print "Enter the URL",
url = raw_input()
r = requests.get(url)
c = r.content
soup = BeautifulSoup(c)
div = soup.find('div' , id ='Custom')
comment = next(div.children)
test = comment.partition(':')[-1].strip()
print test
【问题讨论】:
-
作为旁注,您正在抓取哪个网站使用验证码但在源代码中包含答案?那种完全违背了目的;它甚至没有减慢机器人的速度就惹恼了用户……
-
这是一个我正在为我的网络安全大师工作的实验室。
-
嗯,我还有很多很多的课程要上。如果我能在 C# 生活中编写所有代码会容易得多。学习 python 并不难,但学习所有的库是一头野兽……
-
你看过 IronPython 吗? Python 语言、.NET 库……听起来你可能会喜欢它。
标签: python html web-scraping beautifulsoup captcha