Reputation: 67
I was trying to find out how to incorporate proxies in my code and was directed to this webpage https://requests.kennethreitz.org/en/master/user/advanced/#proxies . They tell me to do the following
import requests
proxies = {
'http': 'http://10.10.1.10:3128',
'https': 'http://10.10.1.10:1080',
}
requests.get('http://example.org', proxies=proxies)
How am I supposed to incorporate this in my code? Here is my code so far
import requests
import instaloader
L = instaloader.Instaloader()
# Login or load session
L.login(username, password) # (login)
# Obtain profile metadata
profile = instaloader.Profile.from_username(L.context, "prada")
# Print list of followees
file = open("prada_followers.txt","a+")
for followee in profile.get_followers():
username = followee.username
file.write(username + "\n")
print(username)
file.close()
Upvotes: 5
Views: 2936
Reputation: 21
proxies = {}
# # in case proxy is from free-proxy-list
# proxies = {
# 'http': f"http://{proxy}",
# 'https': f"https://{proxy}"
# }
# # in case of proxy broker
# parsed = urlparse(proxy)
# proxies = {
# 'http': f"http://{parsed.hostname}:{parsed.port}",
# 'https': f"https://{parsed.hostname}:{parsed.port}"
# }
# # in case of tor proxy running on localhost
# proxies = {
# 'http': 'socks5://127.0.0.1:9050',
# 'https': 'socks5://127.0.0.1:9050'
# }
loader.context._session.proxies = proxies
is how I used to do it
Upvotes: 2