Skip to content

Instantly share code, notes, and snippets.

View MakingPoutine's full-sized avatar
🏠
Working from home

MakingPoutine MakingPoutine

🏠
Working from home
  • Canada
View GitHub Profile
@MakingPoutine
MakingPoutine / [PYTHON]file_get_contents(URL).py
Last active November 20, 2021 23:23 — forked from TwiN/[PYTHON]file_get_contents(URL).py
Python equivalent of PHP's file_get_contents on websites (NOT LOCAL FILES)
import urllib2,cookielib
'''
Function that returns the source from the target url
@param url
'''
def file_get_contents(url):
url = str(url).replace(" ", "+") # just in case, no space in url
hdr = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',