Apify & CrawleeA&CApify & Crawlee
Powered by
sour-pinkS
Apify & Crawlee•16mo ago•
2 replies
sour-pink

Actor is Not changing the IPs after setup Sessions

I'm reaching out to the community for some assistance with an issue I'm encountering while using Playwright and Apify. I've built a scraper that incorporates proxy rotation with sessions, but I'm facing a problem where the proxy isn't changing when the session changes. Additionally, I'd like to ensure the same IP address is used for both the proxy and the captcha solver.

Problem Description:

Playwright script utilizes Apify's proxy configuration with session management.
Proxy rotation is set to occur every 10 downloads.
Session IDs are dynamically generated as my_session{index}.
Despite session switching messages, the proxy server remains the same.

Switching to proxy session: my_session1 with {'server': 'http://10.0.94.249:8011', 'username': 'groups-auto,session-my_session1', '}

Switching to proxy session: my_session2 with {'server': 'http://10.0.94.249:8011', 'username': 'groups-auto,session-my_session2', '}

Switching to proxy session: my_session3 with {'server': 'http://10.0.94.249:8011', 'username': 'groups-auto,session-my_session3', }

Code Snippet;

Create proxy configuration

proxy_configuration = await Actor.create_proxy_configuration(
groups=['auto']
)

...


Proxy and session management logic

total_proxies = 30
download_count = 0
proxy_session_index = 0
results = []

for index, manual in enumerate(manuals[:max_pdfs], start=1):
# ... (download logic)

if download_count % 6 == 0:
proxy_session_index += 1
if proxy_session_index > total_proxies:
proxy_session_index = 1
Actor.log.info("Used all proxies. Sleeping before restarting.")
await asyncio.sleep(10)

session_id = f'my_session{proxy_session_index}'
proxy_url = await proxy_configuration.new_url(session_id)
proxy_settings = get_playwright_proxy_settings(proxy_url)
Actor.log.info(f"Switching to proxy session: {session_id} with server {proxy_settings['server']}")
Apify & Crawlee banner
Apify & CrawleeJoin
This is the official developer community of Apify and Crawlee.
13,739Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements
Recent Announcements
ellativity

**The Apify $1M Challenge is over!** For everyone who joined yesterday’s Award Ceremony livestream for the Apify $1M Challenge, thank you for your enthusiastic drumrolls in the chat and positive vibes. We were really feeling the excitement and celebratory mood! If you missed the stream or just want to rewatch the key moments again, here’s the replay link https://www.youtube.com/watch?v=eEDV-5X43Gg (ngl, the replay is not the same without your live chat) And, if you didn’t check the email that should have landed in your inboxes, we’d love to hear about your experience of participating in the Apify $1M Challenge. **<a:alerthulk:1468892073917939713> Win one of five $100 Visa gift cards by completing the end-of-challenge survey here: https://apify.typeform.com/to/mjoMaZqD** Thank you again to everyone who participated in any capacity. The past 3 months have been a wild ride and we feel so grateful to have been on this adventure with y’all. We mean every word when we say how much you’ve impressed us. Thank you all from the bottom of our hearts. <a:keanuthanks:1430839059655426068> Saurav and Ella xoxo PS - if you just want to jump to the spoilers, a full list of winners is available at https://apify.com/challenge 🏆

ellativity · 5d ago

ellativity

**You are invited** ... to celebrate all the achievements of the Apify $1M Challenge with us on Wednesday, February 4 at **8 AM PT / 11 AM ET / 4 PM GMT / 5 PM CET / 9:30 PM IST / 12 AM +1d CST** We will be announcing winners of the Grand Prizes, as well as regional winners and much more, with especially good news for all participating developers. 🏆 We look forward to sharing with you all! 🎉 More info here: https://luma.com/6c1493t0

ellativity · 2w ago

ellativity

Hi @everyone 👋 I'm hanging out in https://discord.com/channels/801163717915574323/1430491198145167371 for the next 45 min, if you want to discuss the end of the challenge or anything else.

ellativity · 2w ago

Similar Threads

Input-Parameters are not changing when pushing actor?
RapidTech1898RRapidTech1898 / apify-platform
2mo ago
Need help changing my actor price
BoneswillBBoneswill / apify-platform
3mo ago
Apify Actor Input param is not working.
verbal-limeVverbal-lime / apify-platform
3y ago
Why there is 403 error after increase actor memory?
sour-pinkSsour-pink / apify-platform
3y ago