我发现这个python代码用于从bing中提取wordpress网站,有人可以解释这个代码如何只过滤wordpress网站。
try:
lista = []
s = sys.argv[1]
page = 1
print('\n')
while page <= 21:
bing = "http://www.bing.com/search?q=ip%3A"+s+"+?page_id=&count=50&first="+str(page)
openbing = urllib2.urlopen(bing)
readbing = openbing.read()
findwebs = re.findall('<h2><a href="(.*?)"' , readbing)
for i in range(len(findwebs)):
wpnoclean = findwebs[i]
findwp = re.findall('(.*?)\?page_id=', wpnoclean)
lista.extend(findwp)
page = page + 10
final = unique(lista)
for wp in final:
print(wp)
try:
for i , l in enumerate(final):
pass
print '\nSites Found : ' , i + 1
except:
pass
except IndexError:
pass
你想要实现什么目标?您想创建一个只搜索Wordpress的搜索体验吗?如果是,则使用Bing Custom Search API:https://azure.microsoft.com/en-us/services/cognitive-services/bing-custom-search/