Skip to content
Snippets Groups Projects
Commit 9921ebd0 authored by 2mellofanclub's avatar 2mellofanclub
Browse files

6: readme

parent 8d1d86ea
No related branches found
No related tags found
No related merge requests found
# speaker and listener (old)
this part was mainly just following a tutorial
\ No newline at end of file
uses selenium and pychrome
sets up two browsers: the selenium browser does the actual browsing, the pychrome browser uses DevTools to listen to the sent network requests. this example just opens pages and prints out request urls and query strings to the command line. an actual use case could, for example, involve manual operation of the selenium browser window and have the request data tabled in csvs.
shutting down the browsers produces an error, but it should be fine
this was adapted from a tutorial i can no longer find :(
\ No newline at end of file
......@@ -18,8 +18,10 @@ def handle_request_event(*args, **kwargs):
if len(request_query_string) > 0:
print(f"query string: {request_query_string}")
# this selenium browser will do the web browsing
options = webdriver.ChromeOptions()
# arbitrary port number 7777
options.add_argument("--remote-debugging-port=7777")
options.add_argument("--remote-allow-origins=http://localhost:7777")
options.add_argument("--ignore-certificate-errors")
......@@ -33,7 +35,6 @@ tab.call_method("Network.enable", _timeout=20)
tab.set_listener("Network.requestWillBeSent", handle_request_event)
with open("testpages.txt", encoding="utf-8") as pages:
print("\n\n")
for page in pages:
......@@ -45,7 +46,7 @@ with open("testpages.txt", encoding="utf-8") as pages:
except Exception as err:
print(err)
print("All done.")
# wont go clean
# some kind of chicken-and-egg problem with shutting these down, expect errors
tab.stop()
driver.quit()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment