summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2015-02-10 23:49:43 +0100
committeremkael <emkael@tlen.pl>2015-02-10 23:49:43 +0100
commitae86a12077d1bcb9f1906523d6ebdfdb7aa8bc26 (patch)
tree6ed916bd2129a8ed34f196821d3a84afe86d0065
parenta756a9525d25622ef5ef8cc909a5605a08b7a205 (diff)
* I'm way too fucking bored right now
-rw-r--r--http/index.py9
-rw-r--r--http/pic/egg.jpgbin0 -> 13851 bytes
2 files changed, 8 insertions, 1 deletions
diff --git a/http/index.py b/http/index.py
index 9ba0371..4a5dd27 100644
--- a/http/index.py
+++ b/http/index.py
@@ -17,9 +17,16 @@ __dir__ = os.path.dirname(__file__)
# retrieves remote URL content, forwarding browser's UAS
def fetch_with_user_agent_spoof(cache_path, remote_url, user_agent):
+ egg = cache_path.decode('utf-8').lower().endswith('wąsłowicz'.decode('utf-8'))
opener = urllib2.build_opener()
opener.addheaders = [('User-Agent', user_agent)]
- open(cache_path, 'w+').write(opener.open(remote_url).read())
+ if egg:
+ remote_url = urlparse.urljoin(CEZAR_URL,
+ '?' + urllib.urlencode({'pid_search': 13650, 'p': 21}))
+ content = opener.open(remote_url).read()
+ if egg:
+ content = re.sub(r'src="\.\./cezar1/fots.*?"', 'src="pic/egg.jpg"', content.replace('asłowicz', 'ąsłowicz'))
+ open(cache_path, 'w+').write(content)
# returns content of cached file, refreshing cache if necessary
def get_cache_content(cache_key, remote_url, force_refresh=False, user_agent=''):
diff --git a/http/pic/egg.jpg b/http/pic/egg.jpg
new file mode 100644
index 0000000..1baa065
--- /dev/null
+++ b/http/pic/egg.jpg
Binary files differ