从必应中提取WordPress网站

时间:2019-02-27 10:27:52

标签: python wordpress bing

我找到了此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

1 个答案:

答案 0 :(得分:0)

您要达到什么目标?是否要创建仅通过Wordpress搜索的搜索体验。如果是,则使用Bing自定义搜索API:https://azure.microsoft.com/en-us/services/cognitive-services/bing-custom-search/