【发布时间】:2016-11-10 00:36:39
【问题描述】:
我正在尝试制作 python 挑战。 http://www.pythonchallenge.com/pc/def/ocr.html 好的。我知道,我可以将源代码中的代码复制粘贴到 txt 文件中并制作类似的东西,但我想从网上获取它以提高自己。 (+我已经做过了)我试过了
re.findall(r"<!--(.*?)-->,html)
但它什么也得不到。 如果你想要我的完整代码在这里:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests,re
link = "http://www.pythonchallenge.com/pc/def/ocr.html"
x = requests.get(link)
codes = re.findall(r"<!--(.*)-->",str(x.content))
print codes
我也尝试过这样:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests,re
link = "http://www.pythonchallenge.com/pc/def/ocr.html"
x = requests.get(link)
codes = re.findall("<!--\n(.*)\n-->",str(x.content))
print codes
现在它找到了文本,但仍然无法得到那个混乱:(
【问题讨论】:
标签: python html regex python-2.7 web