Created
March 29, 2021 04:50
-
-
Save SeanFelipe/42bd1429732c07862596785a20c535b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
from selenium import webdriver | |
from pdb import set_trace | |
from poms_google import * | |
from html.parser import HTMLParser | |
class HP(HTMLParser): | |
def handle_starttag(self, tag, attrs): | |
#print("start tag: ", tag, attrs) | |
happy = {} | |
interesting = ['value', 'id', 'name', 'type'] | |
pr = tag | |
go = False | |
for att in attrs: | |
if att[0] in interesting: | |
go = True | |
pr += " %s: %s" % (att[0], att[1]) | |
if go: | |
print(pr) | |
driver = webdriver.Chrome() | |
hp = HP() | |
def dump(): | |
# get elements with text | |
#intr = [ el for el in els if el.text != '' ] | |
#for e in intr: | |
for e in els: | |
iid = e.get_attribute('id') | |
pid = e.get_property('id') | |
name = e.get_property('name') | |
val = e.get_property('value') | |
ttype = e.get_property('type') | |
avoid = ['html', 'body'] | |
print("%s %s %s %s %s %s" % (e.tag_name, iid, pid, name, ttype, e.text)) | |
''' | |
if e.tag_name not in avoid: | |
if e.text != '' and val != '': | |
print("%s %s %s %s %s" % (e.tag_name, iid, pid, name, e.text)) | |
''' | |
def parse_dump(): | |
hp.feed(driver.page_source) | |
home = GoogleHome(driver) | |
home.load() | |
els = driver.find_elements_by_xpath('//*') | |
#intr = dump() | |
parse_dump() | |
set_trace() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment