我正在编写一个简单的web scraper脚本,从web页面中提取一个单词。我需要经常更改的单词,但后面是一个从未更改过的单词,所以我可以搜索它。在
到目前为止我的剧本是:
#!/bin/python
import requests
response = requests.get('http://vpnbook.com/freevpn')
print(response.text)
它显然打印了页面的整个HTML。但我需要的是密码:
^{pr2}$
我怎么可能只打印binbd5ar'(或其他替代品)到STOUT?在
Tags:
您可以使用regex搜索。在
“Python基于正则表达式提供了两种不同的基本操作:重新匹配()只检查字符串开头的匹配项,而搜索()检查字符串中任何位置的匹配项“ link
相关问题 更多 >
编程相关推荐