Twitter API search query grouping - python

I am trying to use a search query that either matches where the tweet contains one of multiple hashtags or references a specific account:
"query=(%23food%20OR%20%23tastyt%20OR%20%23delicious%20OR%20%23yum)%20OR%20(%40TwitterFood)%20-is:retweet"
but for some reason this only returns results for tweets referencing the specific account? Anybody able to help with this

Related

How to use python office365-rest-client API update sharepoint list item person field with multiple users?

I am trying to use office365-rest-python-client library to update SharePoint list items person/grouop field with multiple user values. The example I found here (https://github.com/vgrem/Office365-REST-Python-Client/blob/master/examples/sharepoint/listitems/set_lookup_field_value.py) does not quite solve the problem. I can get the site users and parse their ids or other user properties, just need the right syntax to update a (multi) persons field.
me = ctx.web.current_user
# items[0].set_property("AssignedTo", FieldUserValue(me.id)).update().execute_query()
# items[0].set_property("AssignedTo", FieldUserValue.from_user(me)).update().execute_query()

How can I fetch documents from a collection which contains a certain field using mongo engine

I want to fetch a document from a collection i.e Company which contains a certain field i.e Name.
I have tried the following query but it does not work. Can somebody help me in correcting this query or maybe suggest a different query to get what I need? Thanks
Company.objects.get(name__isnull=False)
You can use exists operator
Python.objects(name__exists=True)

User ID's returned from Tweepy are huge numbers that don't link to any accounts

I have been downloading tonnes of tweets for the last few weeks. In order to reduce download time, I only saved tweet user ids not the user account. I need to pass them through a bot check but have now realised that 90% of the user ids are huge numbers (e.g. 1.25103113308656E+018) and cannot be used to search for the account.
Is there a way to convert these back to an account number?
Notes:
The tweet_id column is an equally huge, different number meaning they haven't been read into the wrong column.
When I raise them from the e notation into their raw number it still doesn't work.
I am limited by the week window of the twitter api so I must find a way of linking the data I have already got to individual accounts. This work is for a charitable cause and your help would be greatly appreciated.
The Tweepy API call returns a Response which contains the data in the _json field. You can parse the user key of the said json and extract the IDs and the screen name of the user and store it.
Then you can query the Tweepy api again as per their doc to get the user information.
Please make a note that when you store the ID field, you have to cast it to the String datatype.

Twitter API: is it possible to get number of retweets and number of media images?

Is it possible through the Twitter API to get the total number of retweets a user has? Not just on a specific post, but the total number of retweets associated with a specific account? Or alternatively, what fraction of all tweets were retweeted content rather than original posts?
Also, is it possible to get the number of media images associated with an an account? What I mean is, if you go to a user's page, on the lefthand side it will say something like "2,200 Photos and Videos". Thanks!
Not using the official API, no.
The documentation shows only the following "counts"
followers_count
friends_count
listed_count
favourites_count
statuses_count
If you want the number of media, you can scrape the HTML from the user's Twitter page. Look for the class PhotoRail-headingWithCount
I've not seen anything which shows how many times a user has been retweeted. Where do you see that value?
Actually you can. From Twitter REST APIs: GET statuses/user_timeline:
There is a parameter called include_rts:
When set to false , the timeline will strip any native retweets (though they will still count toward both the maximal length of the timeline and the slice selected by the count parameter). Note: If you’re using the trim_user parameter in conjunction with include_rts, the retweets will still contain a full user object.
So if you want to get count of all retweets you need to set that value to true count all entities and then set it to false and then subtract those values and then you get number of retweets.
NOTE: Also set trim_user to true to get less data(omitting user info of each tweet)
If you want to get count of media, then you need to count all media entities in those tweets: Entities in Objects. To separate them by type, you need to look at the type attribute of each element of media attribute.

Using Twitter Search API with a specific metadata

I've been using the Twitter API (with Python) for quite some time, but I'm unable to search for Twitter users having a specific criterion. For example, the API has several user attributes in the user JSON data it returns, like statuses_count or profile_link_color. But how do I do a reverse search using such parameters, like searching for users who have tweeeted more than 1000 times, or users who have created their accounts last week?
Based on the documentation, it looks like you can search for users that fulfill certain criteria with a GET users/search query:
Provides a simple, relevance-based search interface to public user
accounts on Twitter. Try querying by topical interest, full name,
company name, location, or other criteria.

Categories

Resources