diff options
-rw-r--r-- | http/index.py | 9 | ||||
-rw-r--r-- | http/pic/egg.jpg | bin | 0 -> 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 Binary files differnew file mode 100644 index 0000000..1baa065 --- /dev/null +++ b/http/pic/egg.jpg |