Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Twitter-Mirror für Sidebar #2

Open
pyropeter opened this issue Aug 28, 2012 · 1 comment
Open

Twitter-Mirror für Sidebar #2

pyropeter opened this issue Aug 28, 2012 · 1 comment
Assignees

Comments

@pyropeter
Copy link
Contributor

  • Twitter-Inhalte per Cronjob laden, in DB speichern
  • Komische Twitter-Shorturls auflösen
  • Context-Processor zum Einfügen der Tweets in die Templates
@ghost ghost assigned pyropeter Aug 29, 2012
@pyropeter
Copy link
Contributor Author

Die Web-API ist unter https://twitter.com/i/profiles/show/embassyof/timeline?since_id=238017355886759935

Die ist ein bischen ekelhaft: Man muss HTML parsen, geht aber mit BeautifulSoup ziemlich einfach. Siehe folgenden Pseudopythoncode:

soup = BeautifulSoup(json_load(urlopen(url-von-oben))["items_html"])
t = soup.find_all("div", "tweet")[0]
t("a","js-user-profile-link")[0].get("href") == "/ccchb"
t("span","js-action-profile-name")[0].text == "@ccchb"
t("a","js-permalink")[0].get("href") == "/ccchb/status/238015568572186624"
t("img","js-action-profile-avatar")[0].get("src") == "https://si0.twimg.com/profile_images/241356172/CC ... .png"
t("p","js-tweet-text")[0].text.strip() == "Wir haben jetzt die nächste Veranstal ... C #Bremen /sr"

Die Klassennamen lassen imho darauf schließen, dass der Krams vom Twitter-eigenen JavaScript auch ab und zu mal geparst werden muss. Vielleicht ist die Schnittstelle ja sogar einigermaßen stabil? Wer weiß...

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant