trouble building a twitter scannar

This is the place for queries that don't fit in any of the other categories.

trouble building a twitter scannar

Postby danteOne » Mon Jun 24, 2013 5:53 pm

I am having a lot of trouble getting started on this one project. I want to create a program that monitors many twitter users feeds and records how often certain words are mentioned. I then want to generate a list of words that are being mentioned more than average by the same twitter users.

I have coded python before and taken an intro computer science college course in java, and done a lot of structured programing projects. If I can get the most tweets as strings then I will not have any trouble writing the program. What I am not as comfortable with is projects that involve importing a lot of different packages, dealing with websites or optimization.

I am currently stuck on the very first step. I need to get the lastest tweet from an individual user into a string in python. To do that I have tried to use this "twitter" package but I have had nothing but programs getting it working. https://pypi.python.org/pypi/twitter

I have read through the documentation but it isn't that detailed. I installed the package by typing "python twitter<version> build" and then python sudo twitter<version> install. Something happened without any errors so I know that the package is installed.

I haven't used python in over a year so I must be forgetting some simple import statement. I just want to run the help command for twitter interface. For some reason even that isn't working. (see the code below)

Code: Select all
>>> import twitter
>>> import asdf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named asdf
>>> twitter -h
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'h' is not defined
>>> twitter - h
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'h' is not defined
>>> "twitter -h"
'twitter -h'
>>>
>>> twitter -h
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'h' is not defined
>>> help()

Welcome to Python 2.7!  This is the online help utility.

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics".  Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".

help> twitter.help()
no Python documentation found for 'twitter.help()'

help> twitter.twitter-log
no Python documentation found for 'twitter.twitter-log'


Another reason for this post is to determine if there are any better twitter packages available to use for my purpose.
danteOne
 
Posts: 2
Joined: Mon Jun 24, 2013 4:52 pm

Re: trouble building a twitter scannar

Postby metulburr » Mon Jun 24, 2013 5:56 pm

it would be:
Code: Select all
>>> import twitter
>>> help(twitter)
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1331
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: trouble building a twitter scannar

Postby danteOne » Mon Jun 24, 2013 7:39 pm

alright i got the help files working, but I am still having trouble using the package.
The documentation says
Code: Select all
   
 t = Twitter(
            auth=OAuth(token, token_key, con_secret, con_secret_key)))
   
        # Get your "home" timeline
        t.statuses.home_timeline()
   


But when I try that I get this error.
Code: Select all
>> t = Twitter(auth=OAuth(token,token_key,con_secret, con_secret_key))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'token' is not defined
>>> t.statuses.home_timeline()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 't' is not defined
>>> twitter.statuses.home_timeline()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'statuses'
danteOne
 
Posts: 2
Joined: Mon Jun 24, 2013 4:52 pm

Re: trouble building a twitter scannar

Postby Yoriz » Mon Jun 24, 2013 8:28 pm

Code: Select all
>> t = Twitter(auth=OAuth(token,token_key,con_secret, con_secret_key))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'token' is not defined
You havent assigned anything to token

Code: Select all
>>> t.statuses.home_timeline()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 't' is not defined
t has not been assigned as the previous line was an error

Code: Select all
>>> twitter.statuses.home_timeline()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'statuses'
looks like you shouldn't be calling statuses on the imported twitter module
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 726
Joined: Fri Feb 08, 2013 1:35 am
Location: UK


Return to General Coding Help

Who is online

Users browsing this forum: snippsat and 2 guests