从搜索引擎获取URL结果

时间:2020-02-18 14:46:52

标签: python search

我一直在尝试使用python脚本搜索Google,而不必花钱。我只想说一下,当我输入Dell计算机时,我想知道出现的URL和顺序。以下代码是我最近的尝试之一:

    def __init__(self, name_search):
        self.name = name_search
    def Gsearch(self):
        count = 0
        x = 0
        file = open("googleResults.txt", "w")
        import time
        try:
            from googlesearch import search
        except ImportError:
            print("No Module named 'google' Found")
        while x <= 200:
            for i in search(query=self.name, tld='co.in', lang='en', num=10, start=x, stop=10, pause=60):
                count += 1
                print (count)
                print(i + '\n')
                file.write(str(count) + " " + i + '\n')
            x+= 10
            p = x-10
            print("Displaying results "+ str(p) + "-" + str(x) + '\n')
            print("Sleeping for 1 minutes")
            time.sleep(60.3333)
if __name__ == '__main__':
    gs = Gsearch_python("Dell Computers")
    gs.Gsearch()

现在这可以工作到第141个结果为止,我尝试了所有可能想到的所有形式的等待结果。即使它是指向一些我可以使用的文档的链接,也将不胜感激任何帮助。我愿意使用任何搜索引擎,实际上希望将其调整为使用多个。

谢谢

0 个答案:

没有答案
相关问题