I am trying to write a basic Twitter scraper in Python and while I have it so that it can scrape for hard coded terms, I'm trying to set it to take the search term from user input.
While my if/else statement accepts input when asked, it then fails to run stating that rawinput is not defined. The rawinput is within the if statement I've included my code below
I should mention I'm fairly new to Python.
I've tried removing the rawinput from the if/else and kept it separate but the same issue happens.
userinp = input("Select search type. 1 = tweets. 2 = people")
if userinp == 1:
entry = rawinput
query = u'q='
elif userinp == 2:
entry = rawinput
query = u'f=users&vertical=default&q='
searchurl = baseurl + query + entry
The expected result is that the user selects option 1 or 2 then is asked to enter their search term.
Results are:
Select search type. 1 = tweets. 2 = people1
Traceback (most recent call last):
File "Scrape.py", line 22, in <module>
userentry = rawinput('enter search term')
NameError: name 'rawinput' is not defined
Thanks in advance for any help given.