Twitter data mining: How to analyze Big data with Python (3)

Source: Internet
Author: User

Let's pull up the latest 20 tweets from Twitter account @nytimes.

We can create variables to hold the number of tweets to be pulled (that is, count), and the user to be pulled (that is, name). The User_timeline () function is then called with these two parameters. Here's the updated code (note that you should keep the authentication and API object creation at the top of the code).

# Pass in authentication information and create API Object API = Tweepy. API (auth) # user to pull Weibo name = "NYTimes" # Number of tweets to be pulled Tweetcount = 20 # using the above parameters, call the User_timeline function results = api.user_timeline (i D=name, Count=tweetcount) # Iterates through all of the tweets for tweets in results: # Print the Text field in the Weibo object that exists print Tweet.text

The result of the output looks like this:

Popular applications for this type of data include:

Analyze the specified users to analyze how they interact with the world

Look for Twitter-influenced people and analyze their fans ' trends and interactions

Monitor the change of a user's fans

Example 3: Use keywords to find Weibo

This is the last example: Get the latest tweets that contain a keyword. This is useful if you want to monitor a topic in the Twitter world, or even want to see what your business is talking about. Suppose you want to see what Twitter is talking about Toptal now.

The search () function seems to be the best tool for accomplishing our goals by flipping through the tweept documentation.

The most important parameter here is the q--query parameter, which is the keyword to look for.

You can also set the lang parameter so that only tweets in the desired language will be taken. Only the English ("en") Weibo is returned here.

Now you can modify the code to reflect the changes you want to make. The variables that hold the arguments (query and language) are created first, and then the corresponding functions are called through the API object. Finally, the terminal name of the user who posted the microblog was also printed in the loop.

# Pass in authentication information and create API Object API = Tweepy. API (auth) # you want to find the keyword query = "toptal" # language code (according to ISO 639-1 standard) language = "en" # using the above parameters, call the User_timeline function results = api.sear CH (q=query, Lang=language) # Iterates through all of the tweets for tweets in results: # Prints the text field in the Microblog object print Tweet.user.screen_name, "tweeted:", Tweet.text

The final result looks like this:

Here are some practical ways to use this information:

Create a spatial chart to see where your company is referred to most in the world

Make an emotional analysis of Weibo and see if the overall opinion about your company is positive or negative.

Create a social chart of the hottest users in your company or product-related Weibo

In subsequent articles, you'll cover some of these topics.

Conclusion

Twitter's API interface is very useful in data mining applications, and public opinion can provide a lot of insight. If the Twitter API interface and Big data analytics are something you'll be interested in in the future, it's recommended to check the Twitter API interface, tweepy and Twitter frequency limit guidelines for more information.

In this tutorial, we are simply talking about basic access and pull. However, Twitter's API interface can also be used to serve the intricacies of big data issues, involving people, trends, and social graphs that are so complex that the human mind alone cannot control it.

Ganghong Entertainment juhongyulept.com
New Shellfish Entertainment xinbeiyule.cn
Kat Mei Entertainment jimeiyulept.com
Infinite Entertainment wujiyule88.cn
Colorful Entertainment qicaiyulept.cn

Twitter Data mining: How to analyze Big data with Python (3)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.