xpath

How to scrape all the search results using Selenium webdriver and Python

爷,独闯天下 提交于 2020-05-31 04:55:05
问题 I'm trying to scrape all CRD# from the search result from this site https://brokercheck.finra.org/search/genericsearch/list (You'll need to redo the search when you click on the link, just type some random stuff for the Individual search) I'm using driver.find_elements_by_xpath to target all CRD numbers on each result page. However, I've been playing around with the paths for a while but the webdriver still can't pick up the CRDs from the site. I currently have (in Python) crds = driver.find

Telegram's instant view API: Element <img> is not supported in <p>

℡╲_俬逩灬. 提交于 2020-05-29 10:14:05
问题 I have problem when trying to create my Telegram's Instant View template, with this error: Element <img> is not supported in <p>: <img src="mysrc" /> So, I decided to replace tag <p> if has <img> tag with <figure> tag @replace_tag(<figure>): $body//p//img But the result is not showing the image. FYI, the <img> doesn't have attributes except src . Sample code: <p><img src="mysrc"/></p> I have no idea, please help me 回答1: The problem with your code is it replaces the <img> . Like what you've

Evaluate Xpath2.0 in python

隐身守侯 提交于 2020-05-29 03:18:06
问题 I have an XPath expression as shown below. if(replace(//p[1]/text(),'H','h') = 'hello') then //p[1]/text() else if(//p[1]/text() = 'world') then //p[2]/text() else 'notFound' I want to display which 'if ' expression worked. e.g //p[1]/text() if first 'if' expression worked. 'If' expression can have nested if, for loops and xpath2.0 functions. I can't find any xpath2.0 library for python. So I tried to convert this Js library to python still I can able to split xpath2.0 expression to lexers

How to bring selenium browser to the front?

风格不统一 提交于 2020-05-25 20:04:08
问题 if the browser window is in bg, then this line doesn't work. from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By # available since 2.4.0 from selenium.webdriver.support.ui import WebDriverWait # available since 2.26.0 from selenium.webdriver.support import expected_conditions as EC browser = webdriver.Firefox() browser.get(someWebPage) element = WebDriverWait(browser, 10).until( EC.element_to_be_clickable((By.XPATH, '/

how to fetch '/' separated node/tag name from a given xml in sql

瘦欲@ 提交于 2020-05-24 07:04:51
问题 i want to fetch '/' separated node name from a given xml such that only node/tag name are getting fetched instead of node/tag value from a given xml. Suppose if i have below xml : <ns:manageWorkItemRequest> <ns:wiFocus> <act:orderDate>2020-03-16T10:30:56.000Z</act:orderDate> <act:orderItem> <agr:instance> <spec1:customerServiceIdentifier>ETHA15302121</spec1:customerServiceIdentifier> <spec1:instanceCharacteristic> <spec1:action> <spec1:code>Modify</spec1:code> </spec1:action> <spec1

how to fetch '/' separated node/tag name from a given xml in sql

泪湿孤枕 提交于 2020-05-24 07:04:30
问题 i want to fetch '/' separated node name from a given xml such that only node/tag name are getting fetched instead of node/tag value from a given xml. Suppose if i have below xml : <ns:manageWorkItemRequest> <ns:wiFocus> <act:orderDate>2020-03-16T10:30:56.000Z</act:orderDate> <act:orderItem> <agr:instance> <spec1:customerServiceIdentifier>ETHA15302121</spec1:customerServiceIdentifier> <spec1:instanceCharacteristic> <spec1:action> <spec1:code>Modify</spec1:code> </spec1:action> <spec1

If then else in XPath 1.0

自闭症网瘾萝莉.ら 提交于 2020-05-13 06:35:17
问题 I have the next expression: population = tree.xpath('(//tr/td/b/a[contains(text(), "Population")]/../../following-sibling::td/span/following-sibling::text())[1] or' '//tr/td/b/a[contains(text(), "Population")]/../../following-sibling::td/span/text()) which returns 'True'. If I use "|" instead of 'or', it combines values of the 1st and 2nd paths, like this ['11 061 886', '▼'] . How to make the logic like: If the 1st path exists: get the 1st value elif the 2nd path exists: get the 2nd value

Python - ElementTree- cannot use absolute path on element

青春壹個敷衍的年華 提交于 2020-05-10 03:41:47
问题 I'm getting this error in ElementTree when I try to run the code below: SyntaxError: cannot use absolute path on element My XML document looks like this: <Scripts> <Script> <StepList> <Step> <StepText> </StepText> <StepText> </StepText> </Step> </StepList> </Script> </Scripts> Code: import xml.etree.ElementTree as ET def search(): root = ET.parse(INPUT_FILE_PATH) for target in root.findall("//Script"): print target.attrib['name'] print target.findall("//StepText") I'm on Python 2.6 on Mac. Am

Extract HTML source code without any class or div (python selenium)

♀尐吖头ヾ 提交于 2020-05-09 17:20:10
问题 I have list that does not contain any unique div or class. I want to copy the HTML source code for each row below. I cannot find the class for the row. When I open the 'Edit HTML' I see the following code: <tr style="font-size: 11px"> <td class="center"><a href="/countries/1"><img alt="" src="/assets/flags/flag_1-1db156e1884c1b3d5614b55996cf96cd38843b290c7c43bdd5abbdb944b4075c.gif"></a></td> <td><a href="/employees/9526577">Bernard Aarslev</a></td> <td><a href="/clubs/1200094">Kirslev FC</a><

Extract html source code with selenium xpath

…衆ロ難τιáo~ 提交于 2020-05-09 17:14:58
问题 I want to extract data from a table that is very long. For every row in the table I want to copy a specific HTML code. My HTML source code (which I fully want to extract) looks like: <div class="relative"> <div id="stats9526577" class="dark"></div> <img src="/detaljer-1.gif" onmouseover="view_stats(9526577, 14, 13, 4, 7, 10, 8, 6, 3);"> </div> I tried the python code: data = driver.find_elements_by_xpath('//div[@class="relative"]') How can I print the above HTML source code in python using