我想检索段落包含单词从一个网站。问题我不知道有多少单词后,所以我需要迭代它。遍历单词尽可能多re.search python
import urllib.request
import re
url = "http://www.cnn.com"
request = urllib.request.Request(url)
html_content = urllib.request.urlopen(request)
mystring=html_content.read().decode('utf-8')
m = re.search('CNN\s\w+\s\w+\s\w+\s\w+\s\w+\s\w+\s\w+\s(\w+)',mystring)
print (m.group(0))
在这个例子中
我从韩国CNN的任意不等阶关键字的新闻,例如我想获得的所有段落,直到第一个句号(。),或者可以说punctutaion标志。
不知道你在问什么.. –
添加更多描述到你的问题。 –
用示例尝试... –