#๐ Loop not ending even though condition has been met.
74 messages ยท Page 1 of 1 (latest)
@wispy bolt
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
this part of my function since it doesn't let me send
!code
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
yeah basically
even though the condition is met
here's the log : 2024-08-11T19:51:31.140Z INFO Launching Playwright... 2024-08-11T19:51:35.281Z INFO Webdriver is scrolling... 2024-08-11T19:51:41.376Z INFO Webdriver is scrolling... 2024-08-11T19:52:16.668Z INFO Webdriver is scrolling... 2024-08-11T19:52:52.783Z INFO Webdriver is scrolling... 2024-08-11T19:53:15.676Z Scrolled to the bottom 2024-08-11T19:53:15.809Z Exiting loop and closing browser. 2024-08-11T19:53:23.980Z INFO Webdriver is scrolling... 2024-08-11T19:53:31.850Z INFO Webdriver is scrolling... 2024-08-11T19:54:06.219Z INFO Webdriver is scrolling... 2024-08-11T19:54:43.252Z INFO Webdriver is scrolling... 2024-08-11T19:55:07.196Z Scrolled to the bottom 2024-08-11T19:55:07.311Z Exiting loop and closing browser. it doesn't exit the loop
first of all, what you describe is not what happens, which means something isn't right about your observation
print('Exiting loop and closing browser.')
await browser.close()
return data_list
if you ran that print, then you also either crashed, or ran that return, or entered some other loop in browser.close
more likely, you begin the loop multiple times - ie there's another loop around this
I'm not sure to understand
there's not really another loop and the function is called one time
it isn't possible to stay in the function after those 3 lines, so that can't be what happens
you can easily confirm this by adding a print at the top of the function to see if it is called more than once
I'll try
The only explanation I can see besides the function exiting and being called again is if the function was called multiple times at the start and is interleaving between calls every time an await is reached.
i saw u last time u sure u cant press 'end'? would remove the need for the whole loop.
also where do u assume it doesnt quit the loop?
press end ?
because of the logs
and that the function is called one time
theres the end key it should scroll al the way to the bottom of any website
never heard of that
oh sorry i only read the end and didnt see the exit message being there twice
2024-08-11T20:10:42.771Z Fonction is called
2024-08-11T20:10:45.393Z INFO Webdriver is scrolling...
2024-08-11T20:10:50.907Z INFO Webdriver is scrolling...
2024-08-11T20:11:12.509Z Scrolled to the bottom
2024-08-11T20:11:12.512Z Exiting loop and closing browser.
2024-08-11T20:11:12.900Z Fonction is called
2024-08-11T20:11:17.828Z INFO Webdriver is scrolling...
2024-08-11T20:11:24.683Z INFO Webdriver is scrolling...
2024-08-11T20:11:46.615Z Scrolled to the bottom
2024-08-11T20:11:46.619Z Exiting loop and closing browser.```
you were right
function is called multiple time
but I called it only one time
try:
data = await get_full_html_content(keyword)
except:
try:
error_traceback = traceback.format_exc()
r.post('', json={'content': error_traceback})
except Exception as e:
r.post('', json={'content': 'couldnt get error {e}'})
settings['ITEM_PIPELINES'] = { ActorDatasetPushPipeline: 1 }
settings['TWISTED_REACTOR'] = 'twisted.internet.asyncioreactor.AsyncioSelectorReactor'
settings['DEPTH_LIMIT'] = depth
settings['RETRY_ENABLED'] = False
settings['DOWNLOAD_TIMEOUT'] = 2.5
data = await get_full_html_content(keyword)
if data != 'No result':
process = CrawlerProcess(settings)
process.crawl(
EmailScraper, pattern_list=pattern_list,
crawling_depth = depth, data_dict=data, get_insta_details=insta_details)
process.start()```
the rest of the code
the function is only called one time
u use selenium right?
no, I use playwright
NO
it's called twice
I'm dumb
I just noticed it
bruhhh
I coded for like 5-6 hours straight
that's why I think
I feel so dumb right now
well
I'm ending it
by exiting the function
also pageup/down is way faster than up and down
yes but if you do that
it wil lget buggy
and don't charge the element I need to charge
so that's why I need it to be a little bit slow
oh ok than end is also not ur key here
but the key ends when the function is exited
so it's useless to try end it before exiting
no its the end key it will go to the end of the line or the bottom of the site depending on where u use it
ahhh
nono its a substitute for down but if speed is problem its useless bc it goes to the bottom in one press
with end u dont need to check if u are at the bottom
but if going too fast doesnt load stuff
than tis wont load any
I'll try that tomorrow to see if it works
if it does
it will be really helpful
ty @spice sorrel
!close
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.