Skip to content

Instantly share code, notes, and snippets.

@jabbalaci
Created January 3, 2014 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jabbalaci/8237125 to your computer and use it in GitHub Desktop.
Save jabbalaci/8237125 to your computer and use it in GitHub Desktop.
image extractor for szilvasbukta.com posts without liking it
#!/usr/bin/env python
# encoding: utf-8
"""
Facebook is recently full of szilvasbukta.com links. However, if
you want to see an image, you must like it. WTF? This script extracts
the hidden image and opens it in your browser (in Firefox, by default).
dropped together by Jabba Laci (jabba.laci@gmail.com)
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import os
import urlparse
import requests
from bs4 import BeautifulSoup
#import webbrowser
BASE = "http://szilvasbukta.com"
def get_url_from_user():
return raw_input("szilvasbukta.com full URL: ").strip()
def open_url(url):
#webbrowser.open_new_tab(url)
os.system('firefox -url "{url}" 2>/dev/null'.format(url=url))
def process(url):
r = requests.get(url)
soup = BeautifulSoup(r.text)
div = soup.find("div", {"id": "LikedPost"})
if div:
img = div.find("img")
if img:
pic = urlparse.urljoin(BASE, img['src'])
print(pic)
open_url(pic)
def main():
url = get_url_from_user()
process(url)
##############################################################################
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment