This repository was archived by the owner on Jun 8, 2026. It is now read-only.
Repository navigation
Update Python client to Search API v3 #32
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d0f143c
updated code base to support Twingly Search API v.3
xSAVIKx eb9e4a7
Updated README with correct example
xSAVIKx 0a31b10
updated tests
xSAVIKx 3ec7370
added search for spotify on sv blogs test
xSAVIKx d8a4ef2
updated examples with v3 API usage
xSAVIKx 12db9b8
added Query back with @deprecated notations
xSAVIKx 1e3a4f6
remove duplicated details string
xSAVIKx 70c8a53
updated query and client. cleaned up sources
xSAVIKx 5d1b087
trying to fix problem with Python3 compilation
xSAVIKx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,12 @@ | ||
| from __future__ import division | ||
| from __future__ import print_function | ||
| from __future__ import unicode_literals | ||
|
|
||
| import twingly_search | ||
| import datetime | ||
|
|
||
| client = twingly_search.Client() | ||
| query = client.query() | ||
| query.pattern = '"hello world"' | ||
| query.start_time = datetime.datetime.utcnow() - datetime.timedelta(hours=1) | ||
| results = query.execute() | ||
| q = '"hello world" tspan:24h' | ||
| results = client.execute_query(q) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This example should use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignore the above comment, check the conversation at https://github.com/twingly/twingly-search-api-python/pull/32/files/1e3a4f6b18b4b043e227c6c4020d827720f1104f#r117046935 :) |
||
|
|
||
| for post in results.posts: | ||
| print(post.url) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| future | ||
| requests | ||
| pytz | ||
| deprecation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <twinglydata numberOfMatchesReturned="0" secondsElapsed="0.203" numberOfMatchesTotal="0" incompleteResult="true"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,52 +1,118 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <twinglydata numberOfMatchesReturned="3" secondsElapsed="0.148" numberOfMatchesTotal="3"> | ||
| <post contentType="blog"> | ||
| <url>http://oppogner.blogg.no/1409602010_bare_m_ha.html</url> | ||
| <title><![CDATA[Bare MÅ ha!]]></title> | ||
| <summary><![CDATA[Ja, velkommen til høsten ...]]></summary> | ||
| <languageCode>no</languageCode> | ||
| <published>2014-09-02 06:53:26Z</published> | ||
| <indexed>2014-09-02 09:00:53Z</indexed> | ||
| <blogUrl>http://oppogner.blogg.no/</blogUrl> | ||
| <blogName><![CDATA[oppogner]]></blogName> | ||
| <authority>1</authority> | ||
| <blogRank>1</blogRank> | ||
| <tags> | ||
| <tag><![CDATA[Blogg]]></tag> | ||
| </tags> | ||
| </post><post contentType="blog"> | ||
| <url>http://www.skvallernytt.se/hardtraning-da-galler-swedish-house-mafia</url> | ||
| <title><![CDATA[Hårdträning – då gäller Swedish House Mafia]]></title> | ||
| <summary><![CDATA[Träning. Och Swedish House Mafia. Det verkar vara ett lyckat koncept. "Don't you worry child" och "Greyhound" är nämligen de två mest spelade träningslåtarna under januari 2013 på Spotify. | ||
|
|
||
| Relaterade inlägg: | ||
| Swedish House Mafia – ny låt! | ||
| Ny knivattack på Swedish House Mafia-konsert | ||
| Swedish House Mafia gör succé i USA]]></summary> | ||
| <languageCode>sv</languageCode> | ||
| <published>2013-01-29 15:21:56Z</published> | ||
| <indexed>2013-01-29 15:22:52Z</indexed> | ||
| <blogUrl>http://www.skvallernytt.se/</blogUrl> | ||
| <blogName><![CDATA[Skvallernytt.se]]></blogName> | ||
| <authority>38</authority> | ||
| <blogRank>4</blogRank> | ||
| <tags> | ||
| <tag><![CDATA[Okategoriserat]]></tag> | ||
| <tag><![CDATA[Träning]]></tag> | ||
| <tag><![CDATA[greyhound]]></tag> | ||
| <tag><![CDATA[koncept]]></tag> | ||
| <tag><![CDATA[mafia]]></tag> | ||
| </tags> | ||
| </post><post contentType="blog"> | ||
| <url>http://didriksinspesielleverden.blogg.no/1359472349_justin_bieber.html</url> | ||
| <title><![CDATA[Justin Bieber]]></title> | ||
| <summary><![CDATA[OMG! Justin Bieber Believe acoustic albumet er nå ute på spotify. Han er helt super. Love him. Personlig liker jeg best beauty and a beat og as long as you love me, kommenter gjerne hva dere synes! <3 #sus YOLO]]></summary> | ||
| <languageCode>no</languageCode> | ||
| <published>2013-01-29 15:12:29Z</published> | ||
| <indexed>2013-01-29 15:14:37Z</indexed> | ||
| <blogUrl>http://didriksinspesielleverden.blogg.no/</blogUrl> | ||
| <blogName><![CDATA[Didriksinspesielleverden]]></blogName> | ||
| <authority>0</authority> | ||
| <blogRank>1</blogRank> | ||
| </post> | ||
| </twinglydata> | ||
| <twinglydata numberOfMatchesReturned="3" secondsElapsed="0.369" numberOfMatchesTotal="3122050" incompleteResult="false"> | ||
| <post> | ||
| <id>16405819479794412880</id> | ||
| <author>klivinihemligheten</author> | ||
| <url>http://nouw.com/klivinihemligheten/planering---men-dalig-30016048</url> | ||
| <title>Planering - men dålig</title> | ||
| <text>Det vart en förmiddag på boxen med en brud som jag lärt känna där. Körde en egen WOD, bland annat SDHP, | ||
| shoulder press, HSPU - bland annat. Hade planerat dagen in i minsta detalj, insåg under passet att jag glömt | ||
| leggings. Så - det var bara att sluta lite tidigare för att röra sig hemåt för dusch och lunch. Har alltså | ||
| släpat med mig ryggsäcken med allt för dagen i onödan. Riktigt riktigt klantigt! Har nu en timma på mig att | ||
| duscha och göra mig ordning för föreläsning, innan det är dags att dra igen. Och jag som skulle plugga innan | ||
| </text> | ||
| <languageCode>sv</languageCode> | ||
| <locationCode>se</locationCode> | ||
| <coordinates/> | ||
| <links/> | ||
| <tags> | ||
| <tag>Ätas & drickas</tag> | ||
| <tag>Universitet & studentlivet</tag> | ||
| <tag>Träning</tag> | ||
| <tag>To to list</tag> | ||
| </tags> | ||
| <images/> | ||
| <indexedAt>2017-05-04T06:51:23Z</indexedAt> | ||
| <publishedAt>2017-05-04T06:50:59Z</publishedAt> | ||
| <reindexedAt>2017-05-04T08:51:23Z</reindexedAt> | ||
| <inlinksCount>0</inlinksCount> | ||
| <blogId>5312283800049632348</blogId> | ||
| <blogName>Love life like a student</blogName> | ||
| <blogUrl>http://nouw.com/klivinihemligheten</blogUrl> | ||
| <blogRank>1</blogRank> | ||
| <authority>0</authority> | ||
| </post> | ||
| <post> | ||
| <id>4331268749726303987</id> | ||
| <author>berggrenjulia</author> | ||
| <url>http://nouw.com/berggrenjulia/sometimes-the-king-is-a-queen-30014929</url> | ||
| <title>Sometimes the king is a queen</title> | ||
| <text>Dress / Jumpsuit Hej kompisar! Jag satte ihop två söta plagg till er. Himla gölliga! Jag kan inte fatta | ||
| att det är torsdag idag, det är ju helt sjukt. Vid lunch skall jag till läkaren och W följer med mig pga är | ||
| så rädd för läkaren, får brutal ångest och tror att jag skall bli dödförklarad. Riktigt hypokondrisk blir | ||
| man visst med åren. Usch! Känslan när man går därifrån gör dock att det känns värt det. I helgen funderar vi | ||
| på att gå till Liseberg för det skall bli magiskt väder. Vilken tur för alla bal-peppade kompisar på | ||
| Marstrand! Åh dom kommer ha det fantastiskt kul tror jag. För min egen del måste jag erkänna att jag för | ||
| första gången just nu känner att det skall bli skönt att inte gå. Att få slippa hetsen runt omkring då jag | ||
| blir lite stressad bara av att tänka på det. Har verkligen bromsat ner mitt fest-mode rejält och inte varit | ||
| ute och klubbat på superlänge, är inte speciellt lockad alls. Det är alltid samma visa också, så man kan ju | ||
| trösta sig med att man inte missar någonting. Hur ser eran helg ut? Puss! | ||
| </text> | ||
| <languageCode>sv</languageCode> | ||
| <locationCode>se</locationCode> | ||
| <coordinates/> | ||
| <links> | ||
| <link>http://www.mtpc.se/tags/link/1008098</link> | ||
| <link>http://www.mtpc.se/tags/link/1008099</link> | ||
| </links> | ||
| <tags> | ||
| <tag>Inspiration</tag> | ||
| <tag>Mode</tag> | ||
| <tag>Vardag</tag> | ||
| </tags> | ||
| <images/> | ||
| <indexedAt>2017-05-04T06:51:23Z</indexedAt> | ||
| <publishedAt>2017-05-04T06:50:00Z</publishedAt> | ||
| <reindexedAt>2017-05-04T08:51:23Z</reindexedAt> | ||
| <inlinksCount>0</inlinksCount> | ||
| <blogId>9763611270004865418</blogId> | ||
| <blogName>berggrenjulia blogg</blogName> | ||
| <blogUrl>http://nouw.com/berggrenjulia</blogUrl> | ||
| <blogRank>1</blogRank> | ||
| <authority>5</authority> | ||
| </post> | ||
| <post> | ||
| <id>2770252465384762934</id> | ||
| <author>maartiinasvardag</author> | ||
| <url>http://nouw.com/maartiinasvardag/god-formiddag-30016041</url> | ||
| <title>God förmiddag! ☀️</title> | ||
| <text>Hmm.... Vad ska man börja ?? Jag vet inte riktigt vad min gnista till att blogga har tagit vägen. Jag har | ||
| egentligen massor att skriva om, men ändå blir det inte av att jag gör det. Varför är det så? Någon som | ||
| känner likadant. Kan berätta lite om förra helgen iaf, jag & R åkte till Skövde en sväng på fredagen, | ||
| det blev en hel dag där. Blev en hel del shoppande för oss båda, bilder kommer i ett annat inlägg, då jag | ||
| sitter vid plattan i skrivandets stund. Lördagen var jag hemma med töserna medans R jobbade några timmar. | ||
| Sen blev det bara en lugn kväll hemma. Söndagen så var det dags för mig att jobba, ett dygnspass. ✌️Var en | ||
| lugn kväll på jobbet. På morgonen (måndag) så när jag kommer upp, yrvaken som man är innan första koppen | ||
| kaffe är intagen. Möts jag av att en klient utbrister: Vad glad jag är av att se dig! Detta värmde mitt | ||
| hjärta så oerhört mycket & jag var på strålande humör hela dagen. ❤️ För då vet man att man gör ett bra | ||
| jobb & att man gör rätt för den enskilde klientens behov. Jag älskar mitt jobb, även om jag ibland | ||
| tycker att det är väldigt tufft, men när man får bekräftat att man gjort ett bra jobb, då glömmer man allt | ||
| som är jobbigt. Tisdagen tillbringade jag med att göra ingenting typ, var bara hemma med töserna, solade | ||
| & busade. Satt på baksidan & tjötade med Jonna vid staketet. Ulrika var förbi på en kopp kaffe med | ||
| innan det var dags för henne att åka & jobba. På kvällen blev det sällskapsspel med Nina & Jonna. | ||
| Mycket trevligt. Onsdag blev det lite grejande hemma med att tvätta & plocka lite, tjöta med Jonna i | ||
| vanlig ordning vid staketet. På kvällen blev det ett gympass med Nina & Jonna. ✌️Sen blev det soffan för | ||
| mig & kolla klart på serien Tretton skäl varför. En bra med tung serie där en tjej berättar varför hon | ||
| valde att ta sitt liv. ☹️ Det som skrämmer mig är att det är så här verkligheten ser ut, när det sprids så | ||
| mycket hat. Hur vore det om man började sprida mer kärlek till varandra, acceptera att vi alla är olika | ||
| m.m.? Ja det är nog en fråga som vi aldrig kommer att få svar på. Idag blir det att åka in till stan under | ||
| dagen på lite ärenden, annars är det de gamla vanliga på schemat. Vardags sysslor & R kommer hem, ingen | ||
| är gladare än jag & töserna att få hem honom. ❤️ Önskar er alla en toppen dag! ☀️ | ||
| </text> | ||
| <languageCode>sv</languageCode> | ||
| <locationCode>se</locationCode> | ||
| <coordinates/> | ||
| <links/> | ||
| <tags/> | ||
| <images/> | ||
| <indexedAt>2017-05-04T06:50:07Z</indexedAt> | ||
| <publishedAt>2017-05-04T06:49:50Z</publishedAt> | ||
| <reindexedAt>0001-01-01T00:00:00Z</reindexedAt> | ||
| <inlinksCount>0</inlinksCount> | ||
| <blogId>1578135310841173675</blogId> | ||
| <blogName>maartiinasvardag blogg</blogName> | ||
| <blogUrl>http://nouw.com/maartiinasvardag</blogUrl> | ||
| <blogRank>1</blogRank> | ||
| <authority>0</authority> | ||
| </post> | ||
| </twinglydata> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| <html><body><h1>503 Service Unavailable</h1> | ||
| No server is available to handle this request. | ||
| </body></html> | ||
| <html> | ||
| <body> | ||
| <h1>503 Service Unavailable</h1> | ||
| No server is available to handle this request. | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?><blogstream xmlns="http://www.twingly.com"> | ||
| <operationResult resultType="failure">The API key does not exist.</operationResult> | ||
| </blogstream> | ||
| <error code="40001"> | ||
| <message>Parameter apikey may not be empty</message> | ||
| </error> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?><blogstream xmlns="http://www.twingly.com"> | ||
| <operationResult resultType="failure">Authentication service unavailable.</operationResult> | ||
| </blogstream> | ||
| <error code="50301"> | ||
| <message>Authentication service unavailable</message> | ||
| </error> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?><blogstream xmlns="http://www.twingly.com"> | ||
| <operationResult resultType="failure">The API key does not grant access to the Search API.</operationResult> | ||
| </blogstream> | ||
| <error code="40101"> | ||
| <message>Unauthorized</message> | ||
| </error> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?><blogstream xmlns="http://www.twingly.com"> | ||
| <operationResult resultType="failure">Something went wrong.</operationResult> | ||
| </blogstream> | ||
| <error code="50001"> | ||
| <message>Internal Server Error</message> | ||
| </error> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <twinglydata numberOfMatchesReturned="0" secondsElapsed="0.213" numberOfMatchesTotal="0" /> | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <twinglydata numberOfMatchesReturned="0" secondsElapsed="0.203" numberOfMatchesTotal="0" incompleteResult="false"/> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example doesn't work anymore (it should use the Query class).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does work, as
execute_queryargument isstrThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Yes you're right. I commented this before actually checking the Query class.