Search tweets by site/url - twitter

I want to use the twitter stream api to get tweets where a certain site occure in the "expanded_url" field, that is - find all tweets that links to any page on a specific site.
A search for "cnn.com" would for example find a tweet containing this:
"entities": {
"url": {
"urls": [
{
"expanded_url": "http://edition.cnn.com/2015/06/22/politics/opm-hack-18-milliion/index.html",...
The idea is to find full URI's for content on a domain/site by searching for all expanded_url that contains a site domain (cnn.com in the example here)
I am currently finding theese tweets by using this search:
https://stream.twitter.com/1.1/search/tweets.json?count=100&q=cnn.com
But this will obviously find more tweets than the ones that only has cnn.com in the expanded_url field.
Are there any way to specify a search query that can do a wildcard search in the expanded_url field ?

Related

how to identify the url in tweet is images, video, article or tweet link?

I am collecting tweets. And want to segregate them as per image, videos and articles. Basically tweet segregation based on their media content
Is there any way or logic by which I can recognize that the url in tweet is reffering to some image or video or article ?
For media, you can check the Extended Entities Object. In the object, there is a key named "type" - if the tweet you're analyzing has some media, the value can be one of "photo", "video", "animated_gif".
For articles, you can check the plain Entities Object if the tweet doesn't contains any media when you checked the Extended Entities Object (since media in twitter is URLs too - meaning that if the tweet doesn't contain any media then the URLs contained in the tweet must be a link).
You can get HTML title and description of the link in the Entities Object API, but unfortunately Twitter Cards are not provided by Twitter API - if you need Twitter Card information you should parse the HTML <head> element and get the information yourself. For detais see the Twitter Cards documentation.

Yahoo Placefinder API - city returns neighborhood, which it shouldn't

I want to use the Yahoo Placefinder API for user registration for city input (auto suggest). Based on the documentation I can to the following GET request:
http://where.yahooapis.com/geocode?city=falenty&country=poland&appid=yourappid
If you put this in browser, it gives you some XML:
...
<line1/>
<line2>05-090 Falenty</line2>
<line3/>
<line4>Poland</line4>
<house/>
<street/>
<xstreet/>
<unittype/>
<unit/>
<postal>05-090</postal>
<neighborhood>Falenty</neighborhood>
<city>Raszyn</city>
<county>Pruszkow County</county>
...
But I don't want to search by neighborhood if I was searching by city. If there is no city by this name, I don't want to get any results.
Does anybody have any idea if that is possible or do I need to loop through results and exclude those results where the city is not the same as what was sent in the URI? This is not an elegant solution because sometimes it gives me more than 10 results and not even 1 with the city I was searching for.

twitter: search hashtags in a twitter list

i'm trying to use 'Twitter Search Widget' here searching an #hashtag in a 'Twitter List', but i can't fix the exact query. Someone did it before me?
Thanks in advance, sorry for my poor english.
Francesco
There doesn't seem to be a way to directly search twitter lists using the widget. If you look at the "operators" link on this page:
https://twitter.com/#!/search-home
You can use "from:userid OR from:userid2 #hashtag" to search for #hashtag tweets from specific users, and hashtags work fine - so you could manually build a search for a list if you wanted.
You can see what operators search can take by looking at the advanced search page here:
https://twitter.com/#!/search-advanced
If i understand correctly, you're trying to search for tweets containing a specific #hashtag, authored uniquely by certain list members?
If this is the case, say for example your looking for the hashtag #COVID19 relayed only by #Twitter's list of official Twitter accounts, you could do it with the following Twitter search query:
#COVID19 list:84839422
Try it...
The structure is quite simple...
[#hashtag] list:[list_id]
You can find list IDs by looking at the URL line in the browser when opening lits on Twitter. For example, here is the URL of #Twitter's official accounts liss:
https://twitter.com/i/lists/84839422
The list ID are the digits after the last /.

Twitting URLs with # in them and getting their count

The goal here is to be able to "tweet" a link of the format
www.example.com/page.aspx#1, and get the number of "tweets" for that link... Basically, what the out-of-the-box Twitter button does for any normal link.
Reason for this is because the page displays different content based on the ID after the #, so there is a need to count which specific item was "tweeted" and how many times.
I tried passing that URL to the Twitter service to get the count (http://urls.api.twitter.com/1/urls/count.json?url=), but the JSON object I get back only has
{"count":0,"url":"www.example.com/page.aspx/"}.
The link for the Twitter button looks like this (done in JavaScript)
var twtLink = 'http://twitter.com/intent/tweet?url='+encodeURIComponent(twtUrl)+'&counturl='+encodeURIComponent(twtUrl);
Any suggestions would be appreciated.
Thanks!
Twitter actually re-interrupts all URL's with their own custom t.co wrapper. This is good news for your use case. You can use these unique t.co links with the counter API.
If you include the attribute &include_entities=1 to the end of some Twitter REST API calls you get back expanded info including the URL's in the tweets. You will see the original URL as well as the shortened URL version. Pass the shortened URL version into the counter API.

How to include the search query of a search engine into my title?

i have often seen websites which are indexed in search engines with a content like: Search now for "search query" ("search query" is the word I have entered in the search engine (for example Google)). So somehow they take the search query and put it into their title. Is there a possibility to do this and if yes, does Google like it or not?
Your page would need to use the HTTP referrer header to determine what the query to the search engine was. It could then use that information to determine what words to highlight on the page, include in the title, etc.

Resources