Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
## Import libraries and functions needed
## define URL
def get_url(All = None, Exact = None, Any = None, Not = None, Hashtag = None, From = None, To = None, Mention = None, Near = None, Dates = None):
#Base URL
url = "https://twitter.com/search?l=&q="
# All
if All != None:
a = All.replace(" ", "%20")
url = url + a
#Exact
if Exact != None:
b = Exact.replace(" ", "%20")
url = url + "%22" + b + "%22"
#Any
if Any != None:
c = Any.replace(" ", "%20OR%20")
url = url + "%22" + c + "%22"
#Not
if Not != None:
d = Not.replace(" ", "%20-")
url = url + "%20-" + d
#Hashtag
if Hashtag != None:
e = Hashtag.replace(" ", "%20OR%20%23")
url = url + "%23" + e
#From
if Hashtag != None:
f = Hashtag.replace(" ", "%20OR%20%23")
url = url + "%23" + f
#To
#Mention
#Near
#Dates
#Base URL end
url = url + "&src=typd"
return(url)
print(get_url())
## Scrape URL
# Create csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.