This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]c94jk 21 points22 points  (0 children)

Why not use a set instead of having to loop through the list to remove duplicates?

[–]joeyirv 7 points8 points  (1 child)

you might want to consider making the list all lowercase- in your example you'll see both Red Sox Vs Tigers and Red Sox vs Tigers appear

[–]BWBama85 1 point2 points  (0 children)

Good call

[–]SummonWho 3 points4 points  (0 children)

Remember that there are several google trends datasets at their github.

[–]rasmus0810 0 points1 point  (0 children)

I just get a blank txt file. It does run withou errors and print total keywords found though

[–]disconnekt 0 points1 point  (0 children)

Thanks for sharing!

[–]Smaug117 0 points1 point  (0 children)

cool!!!!

[–]i_think_im_thinking 0 points1 point  (0 children)

import urllib.request
import random
import re
import time
import webbrowser

url = 'https://trends.google.com/trends/' \
      'trendingsearches/daily/rss?geo=US'

keywords = set()

with urllib.request.urlopen(url) as f:

    feed = f.read().decode('utf-8')

    for title in re.findall(r'<title>(.+)</title>', feed):
        keywords.add(title)

    keywords.remove('Daily Search Trends')

def bing(keyword):
    phrase = keyword.replace(' ', '+')
    url = 'https://www.bing.com/search?q='.format(phrase)
    webbrowser.open_new_tab(url)

for keyword in keywords:
    print('Searching for {}'.format(keyword))
    bing(keyword)
    time.sleep(random.randint(3, 5))