This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import urllib2 | |
class Bing: | |
def __init__(self): | |
self.__bing_url = "http://www.bing.com/search?q=%s&first=%s" | |
def search(self, _s_search): | |
i_page = 1 | |
urls = [] | |
while True: | |
try: | |
i_len_urls = len(urls) | |
response = urllib2.urlopen(self.__bing_url % (_s_search, i_page)) | |
parsed_response = BeautifulSoup(response) | |
for h in parsed_response.findAll("h2"): | |
if h.a != None: | |
s_url = h.a['href'] | |
if s_url in urls: | |
continue | |
elif s_url.startswith("http://") or s_url.startswith("https://") or s_url.startswith("ftp://"): | |
urls.append(s_url) | |
if len(urls) <= i_len_urls: | |
break | |
i_page = i_page + 10 | |
except: | |
pass | |
return urls | |
b = Bing() | |
urls = b.search("bing") | |
print len(urls) | |
print '\n'.join(urls) |
Partial output of the above Python script is shown below:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
194 | |
http://www.bing.com/ | |
http://en.wikipedia.org/wiki/Bing | |
http://www.facebook.com/Bing | |
https://twitter.com/Bing | |
http://www.bingtoolbar.com/en-US | |
http://www.youtube.com/user/bing | |
http://dictionary.reference.com/browse/bing | |
https://www.bingplaces.com/ | |
http://www.thefreedictionary.com/Bing | |
http://43007555.r.msn.com/?ld=Dv_gnZ2ILAtTZR03P_3NWe4zVUCUyjVAbTHjJXdVp5pSJIfJyHoemQp9Uv_Wg6SZdsdEiXBfrZKs_SwYbqptHU6UyPdLC3XaylUED9ff_6c2EI5qNivG3i7FrVBH9_t3zJWhM63Utu8WncH9sAtJdZqlrMdY0&u=WindowFixed.com%2fone.php%3fremove%3dBing+Toolbar | |
http://3228102.r.msn.com/?ld=DvyB-NuRzghUJI5dayAAZZAzVUCUwcmn0K1FdQtdfmLCMQPUz3gc2BgUvJCHT8SlQgGQSrDGzPO89LJdfVC7Mg0Lnx22SO5JX7z0QT-CucKVea58oXWY5s-qrEpTLwMJKuUHNDA_udfLkpaKdohpE6EwelEPY&u=http%3a%2f%2fwww.ask.com%2fslp%3f%26q%3dwhat%2bis%2bbing%26sid%3d0c053e1c-66a9-4f01-ae7d-401fd0f4370f-0-us_msb%26kwid%3dbing%26cid%3d5787895127 | |
http://advertise.bingads.microsoft.com/en-us/home | |
http://blogs.bing.com/webmaster/?p=8413 | |
http://blogs.bing.com/ | |
http://hk.bing.com/ | |
http://advertise.bingads.microsoft.com/en-us/sign-up | |
http://en.wikipedia.org/wiki/Bing_(company) | |
http://www.microsoft.com/privacystatement/en-gb/bing/default.aspx | |
http://msdn.microsoft.com/en-us/library/dd877956.aspx | |
http://43007555.r.msn.com/?ld=d3odkhGgduicmifMUqm19BRTVUCUxkRtc4JCtSzSlX8koKvNTxhK6ZCc0xg7F2lL1VzUHlg0d091QCJzID_AFXhoaYV_qheV-DwL010iIeyGhkidZmY4BbDgkbsV4S7Y02EUygVci2nzFRJXxoML4rBHKB5GM&u=WindowFixed.com%2fone.php%3fremove%3dBing+Toolbar | |
https://addons.mozilla.org/en-US/firefox/addon/bing/ | |
http://www.microsoft.com/maps/ | |
https://www.bingmapsportal.com/ | |
http://www.bingiton.com/ | |
https://itunes.apple.com/us/app/bing/id345323231 | |
http://www.merriam-webster.com/dictionary/bing | |
http://bing.en.softonic.com/ |