Replies: 5 comments
-
|
Without a url and code nobody could give advice |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for your reply. I am traveling for a few days so it will take a few to get back to you with specifics. The site I am going after right now has to be logged into so I’ll figure something out that I can share.
I had thought that somewhere there was a working model that I might study and learn from. I think that you are currently responsible for NoDriver and it is an amazing piece of work. It does seem to avoid detection and it is blazingly fast and reliable. Thanks for your efforts on our behalf.
From: Leon ***@***.***>
Sent: Saturday, November 8, 2025 6:43 PM
To: ultrafunkamsterdam/undetected-chromedriver ***@***.***>
Cc: shankboy ***@***.***>; Author ***@***.***>
Subject: Re: [ultrafunkamsterdam/undetected-chromedriver] NoDriver and iframes (Discussion #2274)
Without a url and code nobody could give advice
—
Reply to this email directly, view it on GitHub <#2274 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AJVQG63IF3NYWSRQOVNIAQT33Z5ZVAVCNFSM6AAAAACLQROXLOVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTIOJRGI4TQMQ> .
You are receiving this because you authored the thread. <https://github.com/notifications/beacon/AJVQG63L4S3JAFOQJ6EZUFT33Z5ZVA5CNFSM6AAAAACLQROXLOWGG33NNVSW45C7OR4XAZNRIRUXGY3VONZWS33OINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQA4OG5M.gif> Message ID: ***@***.*** ***@***.***> >
|
Beta Was this translation helpful? Give feedback.
-
|
Here is a posting that is supposed to work (https://www.google.com/search?client=firefox-b-1-d&channel=entpr&q=who+maintains+nodriver&udm=50&fbs=AIIjpHxU7SXXniUZfeShr2fp4giZ1Y6MJ25_tmWITc7uy4KIeqDdErwP5rACeJAty2zADJgYJpo1blvMpITBRgbnARM6y8KwxzRsF24u6g33NutBQg5oTaOPEjih5eaMj6wzNwV6XxSRQAWh3N3C-OcFalMGEXLKhO8uvEtBAgDCqpGe5FRlLXz2wudEAVz6YQt9mVfNp5bMYidvA9GA8nq3f874oPkSTg&ved=2ahUKEwjhltebr9uQAxUgi7AFHUW2BbUQ0NsOegQIAxAB&aep=10&ntc=1&mtid=GnMLaYe1K52dwbkPp9bUsQQ&mstk=AUtExfAmqQfAjnX1er5hQYvYtZ_78q7qJlQEvHAoS8Hv4eUigx9euG7rhN6XNdWnqHDMsDBOnUVsC4rn3BreBl4z6yaEmzn6V2-UHGaCtskPBzolDPL1JrMICtm2IjaiEeZG33uBjltXfSWVwx5T0p07LH1PVGwybbm4srwx_qZkwf6FAnUYbPaHHqTl2RdWCDXS9ly-JWFpCSPZK2K-P626Sk1_aFfEjv8-bR5y2UJTbfpzrw3yAg3xQmcfyhkUg4cnAvwLHwaT-ltORKOF0Zs49c30NnErGbJu1qLcduTeLQmLMnXepfu3Jni7Uys2cZmGKQ5ATK_nPw8UAA&csuir=1)
Here is the code:
import nodriver as uc
import asyncio
async def switch_frame(browser, frame) -> uc.Tab:
frame_id = "temp"
print("Line 7", frame)
"""Helper function to switch to the iframe's context."""
# Filter through all browser targets to find the one matching the iframe's frame_id
iframe_tab: uc.Tab = next(
filter(
lambda x: str(x.target.target_id) == str(frame.frame_id), browser.targets
)
)
# Optional: Replace "iframe" with "page" in the websocket URL for full page context
# iframe_tab.websocket_url = iframe_tab.websocket_url.replace("iframe", "page")
return iframe_tab
async def main():
browser = await uc.start()
tab = await browser.get("https://iframetester.com/?url=https://keyboard-test.space") # Example site with an iframe
# Wait for the iframe content to load
await tab.sleep(2)
# 1. Locate the iframe element in the main tab
iframes = await tab.select("iframe") # This returns a list of elements
print("Line 29", iframes)
if not iframes:
print("No iframe found.")
return
iframe_element = iframes[0] # Assuming we want the first iframe
# 2. Get the new tab (context) for the iframe
iframe_tab = await switch_frame(browser, iframe_element)
print(f"Switched context to iframe_tab: {iframe_tab}")
# 3. Interact with elements inside the iframe using the new tab object
# For example, select an element inside the iframe by its selector:
element_inside = await iframe_tab.select("textarea") # Use the iframe_tab to select elements within it
if element_inside:
print(f"Found element inside iframe: {element_inside.description}")
await element_inside.send_keys("Hello, NoDriver!")
await iframe_tab.sleep(3)
else:
print("Element inside iframe not found.")
await browser.sleep(5)
await browser.close()
if __name__ == "__main__":
uc.loop().run_until_complete(main())
When I run it (I added two print statements to try to see what is going on) it fails with the following output:
C:\MyStuff\Travels\Python312\python.exe "C:\MyStuff\Travels\Python312\Projects\Mail Application 25-03-08\temp.py"
Line 29 <iframe id="iframe-window" src="https://keyboard-test.space" style="display: block;"></iframe>
Line 7 None
Traceback (most recent call last):
File "C:\MyStuff\Travels\Python312\Projects\Mail Application 25-03-08\temp.py", line 56, in <module>
uc.loop().run_until_complete(main())
File "C:\MyStuff\Travels\Python312\Lib\asyncio\base_events.py", line 664, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\MyStuff\Travels\Python312\Projects\Mail Application 25-03-08\temp.py", line 37, in main
iframe_tab = await switch_frame(browser, iframe_element)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\MyStuff\Travels\Python312\Projects\Mail Application 25-03-08\temp.py", line 10, in switch_frame
iframe_tab: uc.Tab = next(
^^^^^
File "C:\MyStuff\Travels\Python312\Projects\Mail Application 25-03-08\temp.py", line 12, in <lambda>
lambda x: str(x.target.target_id) == str(frame.frame_id), browser.targets
^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'frame_id'
successfully removed temp profile C:\Users\pinev\AppData\Local\Temp\uc_278zgz9s
Process finished with exit code 1
It appers to me that the “iframe_element = iframes[0]” line of code (line 34) causes iframe_element to be blank and that causes a problem in switch_frame.
Perhaps this is one example I could follow if it worked…I am sorry to lean on you and appreciative of any help provided and your time.
From: Leon ***@***.***>
Sent: Saturday, November 8, 2025 6:43 PM
To: ultrafunkamsterdam/undetected-chromedriver ***@***.***>
Cc: shankboy ***@***.***>; Author ***@***.***>
Subject: Re: [ultrafunkamsterdam/undetected-chromedriver] NoDriver and iframes (Discussion #2274)
Without a url and code nobody could give advice
—
Reply to this email directly, view it on GitHub <#2274 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AJVQG63IF3NYWSRQOVNIAQT33Z5ZVAVCNFSM6AAAAACLQROXLOVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTIOJRGI4TQMQ> .
You are receiving this because you authored the thread. <https://github.com/notifications/beacon/AJVQG63L4S3JAFOQJ6EZUFT33Z5ZVA5CNFSM6AAAAACLQROXLOWGG33NNVSW45C7OR4XAZNRIRUXGY3VONZWS33OINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQA4OG5M.gif> Message ID: ***@***.*** ***@***.***> >
|
Beta Was this translation helpful? Give feedback.
-
|
It seems like you are testing iframes for the sake of testing iframes. A specialized site for it will always win. When you use expert=True on start(), find()/find all() will return everything, also in iframes. But in this mode you will be detectable by antibot. In practice of web scraping the only ones using these techniques are anti bot companies or specialized testing sites. And for antibot you can just run in non expert mode you will hardly encounter them. And if so you can just use verify_cf(). |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for your second email…I am trying to build a general purpose module that I can then customize to virtually any website, including those utilizing datadome. So my module will contain logic for all/most of the conditions that NoDriver handles. AS I have said, I have run into a dead end with iframes. I can assure you I have tried and read a lot, but still no solution has emerged.
I have simplified what I am trying to build to go into a specific website and try to access a field that is embedded within an iframe so that you can help with a specific set of conditions. I have attached the code (first attached file), the HTML for the website (second file) and the results obtained (below). I have embedded a number of print statements so that progress can be monitored. As you can see, the routine is able to find the iframe (Line 54 iframe =…) and it then looks for a field within the iframe using the xpath address. However, this fails and times out (Iframe error: time ran out while waiting for text: /html/body/form/div[4]/div[2]/div/div/div/div[2]/ng-form/div[4]/div[2]/div[2]/div/div[1]/div[1]/input) which is generated in the except that follows the try condition. The site is password protected and I’d prefer not to share that information, but if that is the only way you can help me, then I’ll do it.
I greatly appreciate your time and will do my best to document whatever solution you share with me since I can’t find a working one out there. That way others would be able to find a solution more easily and without bothering you.
Thanks again for the time and effort invested int NoDriver it seems awfully strong and it runs very quickly – I have been timing out various activities and the results are really good.
C:\MyStuff\Travels\Python312\python.exe "C:\MyStuff\Travels\Python312\Projects\Mail Application 25-03-08\temp11-16.py"
Line 50 <a id="p_lt_Header_MyProfilePages_lnkEditProfile" class="MyProfile_FullLink" href="/Roster/Roster.aspx#/edit/2137597">Edit My Profile</a>
Line 52 <Tab [4F92A219B0FE10CBE9B67B7D93808916] [page] [url: https://www.meriongolfclub.com/Member-Central.aspx]>
Line 54 iframe = <iframe id="module" class="moduleIframe" src="" frameborder="0" scrolling="no"></iframe>
Page 55 <Tab [4F92A219B0FE10CBE9B67B7D93808916] [page] [url:
https://www.meriongolfclub.com/Roster/Roster.aspx#/edit/2137597]>
Iframe error: time ran out while waiting for text:
/html/body/form/div[4]/div[2]/div/div/div/div[2]/ng-form/div[4]/div[2]/div[2]/div/div[1]/div[1]/input
Line 28
Line 62
successfully removed temp profile C:\Users\pinev\AppData\Local\Temp\uc_3006r47_
Exception ignored in: <function BaseSubprocessTransport.__del__ at 0x000001F66514B880>
Traceback (most recent call last):
File "C:\MyStuff\Travels\Python312\Lib\asyncio\base_subprocess.py", line 126, in __del__
File "C:\MyStuff\Travels\Python312\Lib\asyncio\base_subprocess.py", line 104, in close
File "C:\MyStuff\Travels\Python312\Lib\asyncio\proactor_events.py", line 109, in close
File "C:\MyStuff\Travels\Python312\Lib\asyncio\base_events.py", line 772, in call_soon
File "C:\MyStuff\Travels\Python312\Lib\asyncio\base_events.py", line 519, in _check_closed
RuntimeError: Event loop is closed
Process finished with exit code 0
From: Leon ***@***.***>
Sent: Sunday, November 9, 2025 6:33 AM
To: ultrafunkamsterdam/undetected-chromedriver ***@***.***>
Cc: shankboy ***@***.***>; Author ***@***.***>
Subject: Re: [ultrafunkamsterdam/undetected-chromedriver] NoDriver and iframes (Discussion #2274)
It seems like you are testing iframes for the sake of testing iframes. A specialized site for it will always win. When you use expert=True on start(), find()/find all() will return everything, also in iframes. But in this mode you will be detectable by antibot. In practice of web scraping the only ones using these techniques are anti bot companies or specialized testing sites. And for antibot you can just run in non expert mode you will hardly encounter them. And if so you can just use verify_cf().
—
Reply to this email directly, view it on GitHub <#2274 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AJVQG64ZFRC7GSTSGTMLV5L334Q7RAVCNFSM6AAAAACLQROXLOVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTIOJRGQ4TEMQ> .
You are receiving this because you authored the thread. <https://github.com/notifications/beacon/AJVQG63PKEKPP4COBI3BCQ3334Q7RA5CNFSM6AAAAACLQROXLOWGG33NNVSW45C7OR4XAZNRIRUXGY3VONZWS33OINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQA4OKWU.gif> Message ID: ***@***.*** ***@***.***> >
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have spent many hours reading, testing and retesting trying to get this wonderful library to work with iframes. Despite what the documentation says, i can't seem to get there. All of my research on stackoverflow, google, etc. has not led to a working solution. The code examples i have found don't work when tested in my environment. Can anyone point me to a solution that works that i can emulate? I have an application i am working on and this is the only thing holding me back.
Thanks in advance for your help - [email protected]
Beta Was this translation helpful? Give feedback.
All reactions