【发布时间】:2016-09-17 17:51:00
【问题描述】:
所以,我决定通过学习一门新语言并开始构建机器人来提高我的编程技能。 “hackthissite.org”有几个我想完成的编程挑战。第一个是解读一些单词。
好的,很简单。让我创建一个脚本,首先登录并隔离单词。
我似乎无法在 15 秒内连接到该网站。我正在使用“请求”API 来执行此操作。这是我的代码:
def main():
print("Starting Prograam")
session = requests.session()
session = requests.get("https://www.hackthissite.org/pages/index/index.php")
print(str(session.status_code))
print("Successfully Connected to the site") #TODO: Error Handling
login = {'username' : 'My Account Username', 'password' : 'Terrible Hard-coded Password Here'}
session = requests.post("https://www.hackthissite.org/user/login", data=login)
bs = BeautifulSoup(session.content, "html.parser")
print(bs.prettify())
main()
该程序运行了 11 年,但我最终得到了超时错误或等待了一段我知道我不应该等待的荒谬时间。我似乎无法在互联网上找到和我有同样问题的人。 “hackthissite.org”是针对机器人的吗?我是否需要以某种方式掩盖我作为用户的活动?
【问题讨论】:
标签: python-3.x http python-requests bots