-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy path05_proxy_rotation.py
More file actions
31 lines (27 loc) · 1.12 KB
/
05_proxy_rotation.py
File metadata and controls
31 lines (27 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from apify import Actor
async def main() -> None:
async with Actor:
proxy_configuration = await Actor.create_proxy_configuration(
proxy_urls=[
'http://proxy-1.com',
'http://proxy-2.com',
],
)
if not proxy_configuration:
raise RuntimeError('No proxy configuration available.')
proxy_url = await proxy_configuration.new_url() # http://proxy-1.com
proxy_url = await proxy_configuration.new_url() # http://proxy-2.com
proxy_url = await proxy_configuration.new_url() # http://proxy-1.com
proxy_url = await proxy_configuration.new_url() # http://proxy-2.com
proxy_url = await proxy_configuration.new_url(
session_id='a'
) # http://proxy-1.com
proxy_url = await proxy_configuration.new_url(
session_id='b'
) # http://proxy-2.com
proxy_url = await proxy_configuration.new_url(
session_id='b'
) # http://proxy-2.com
proxy_url = await proxy_configuration.new_url(
session_id='a'
) # http://proxy-1.com