-1

I find this python code for extract wordpress sites from bing ,can someone explain how this code filter only wordpress sites.

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
Duck Dodgers
  • 3,409
  • 8
  • 29
  • 43
Brahim
  • 1

1 Answers1

0

What are you trying to achieve? Do you want to create a search experience, that will search through only Wordpress. If yes, then use Bing Custom Search API: https://azure.microsoft.com/en-us/services/cognitive-services/bing-custom-search/