getattribute

How to get the price as a number from a website using Selenium and Python

眉间皱痕 提交于 2021-02-10 18:02:51
问题 I am creating a bot that would automate my work and copy particular values from a particular website. Everything works fine but the last lines of my code that says w.text produces an outcome which is text and I need a number. Each element that I need the value of looks like this after inspection: <span class="good">€25,217.65</span> How do I get the value as a number instead of as a text? I tried w.value or w.get_attribute('value) but it doesn't work. Here is my program (excluding downloads

How to locate the last web element using classname attribute through Selenium and Python

若如初见. 提交于 2021-02-05 08:47:05
问题 getphone = driver.find_element_by_class_name('_3ko75')[-1] phone = getphone.get_attribute("title") Not working I need to get the title on string format. Exception has occurred: TypeError 'WebElement' object is not subscriptable File "C:\Users\vmaiha\Documents\Python Projects\Project 01\WP_Answer.py", line 43, in check getphone = driver.find_element_by_class_name('_3ko75')[-1] 回答1: Based on your code trials, to get the title of the last WebElement based on the value of the classname attribute

How get the text from the <p> tag using XPath Selenium and Python

坚强是说给别人听的谎言 提交于 2021-02-05 07:39:16
问题 I need to catch with XPath one line from a text inside a <p> . I need to store the text Content-type: text/plain; charset=us-ascii into a variable in python but i get the next error: selenium.common.exceptions.WebDriverException: Message: TypeError: Expected an element or WindowProxy, got: [object Text] {} Here is the code im trying: import selenium.webdriver as webdriver browser = webdriver.Firefox() browser.get('https://www.w3.org/Protocols/rfc1341/7_1_Text.html') foo = browser.find_element

Detect if a __getattribute__ call was due to hasattr

僤鯓⒐⒋嵵緔 提交于 2021-01-21 11:18:24
问题 I'm re-implementing __getattribute__ for a class. I want to notice any incorrect (meaning failures are expected, of course) failures of providing attributes (because the __getattribute__ implementation turned out quite complex). For that I log a warning if my code was unable to find/provide the attribute just before raising an AttributeError . I'm aware: __getattribute__ implementations are encouraged to be as small as simple as possible. It is considered wrong for a __getattribute__

Detect if a __getattribute__ call was due to hasattr

二次信任 提交于 2021-01-21 11:18:04
问题 I'm re-implementing __getattribute__ for a class. I want to notice any incorrect (meaning failures are expected, of course) failures of providing attributes (because the __getattribute__ implementation turned out quite complex). For that I log a warning if my code was unable to find/provide the attribute just before raising an AttributeError . I'm aware: __getattribute__ implementations are encouraged to be as small as simple as possible. It is considered wrong for a __getattribute__

Detect if a __getattribute__ call was due to hasattr

ⅰ亾dé卋堺 提交于 2021-01-21 11:16:29
问题 I'm re-implementing __getattribute__ for a class. I want to notice any incorrect (meaning failures are expected, of course) failures of providing attributes (because the __getattribute__ implementation turned out quite complex). For that I log a warning if my code was unable to find/provide the attribute just before raising an AttributeError . I'm aware: __getattribute__ implementations are encouraged to be as small as simple as possible. It is considered wrong for a __getattribute__

Finding if element is visible (JavaScript )

放肆的年华 提交于 2020-01-01 02:46:26
问题 I have a javascript function that tries to determine whether a div is visible and does various processes with that variable. I am successfully able to swap an elements visibility by changing it's display between none and block; but I cannot store this value... I have tried getting the elements display attribute value and finding if the the element ID is visible but neither has worked. When I try .getAttribute it always returns null; I am not sure why because I know that id is defined and it

To use getAttribute(), or not to use getAttribute(): that is the question [duplicate]

心不动则不痛 提交于 2019-12-30 04:24:05
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: JavaScript setAttribute vs .attribute= javascript dom, how to handle "special properties" as versus attributes? Many times, in forums or places such as Usenet I have been told by some (when criticizing my code) that instead of saying, for example var link = a.href I should use var link = a.getAttribute('href'); instead. And use its complementary setAttribute() when wanting to assign. They say it is the correct

Understanding the difference between __getattr__ and __getattribute__

时光毁灭记忆、已成空白 提交于 2019-12-28 01:39:40
问题 I am trying to understand the difference between __getattr__ and __getattribute__ , however, I am failing at it. The answer to the Stack Overflow question Difference between __getattr__ vs __getattribute__ says: __getattribute__ is invoked before looking at the actual attributes on the object, and so can be tricky to implement correctly. You can end up in infinite recursions very easily. I have absolutely no idea what that means. Then it goes on to say: You almost certainly want __getattr__ .

ExifInterface returns null for all Tags

余生长醉 提交于 2019-12-25 02:25:10
问题 I have a problem with my class, when i call .getMake(); it always returns null, so I get the string "No Data". I know that Uri is not null because i get ther first Toast every time, with the uripath. I also know that the image has the tag "TAG_MAKE" (I checked it). It even didn't work with all the other tags. What should I change? public class ExifE { private Uri uri; private ExifInterface exifI; private Context context; public ExifE(Context con) { context = con; SharedPreferences prefs =