Skip to content
Advertisement

Find Value Using Selenium using a Variable that Contains String

I am trying to open up several URL’s (because they contain data I want to append to a list). I have a logic saying "if amount in icl_dollar_amount_l" then run the rest of the code. However, I want the script to only run the rest of the code on that specific amount in the variable "amount".

Example:

selenium opens up X amount of links and sees ['144,827.95', '5,199,024.87', '130,710.67'] in icl_dollar_amount_l but i want it to skip '144,827.95', '5,199,024.87' and only get the information for '130,710.67' which is in the 'amount' variable already.

Actual results:

Its getting webscaping information for amount '144,827.95' only and not even going to '5,199,024.87', '130,710.67'. I only want it getting webscaping information for '130,710.67' because my amount variable has this as the only amount.

JavaScript

file2.py

JavaScript

Advertisement

Answer

I don’t know if I understand problem but this

JavaScript

doesn’t give information on which position is '130,710.67' in icl_dollar_amount_l and you need also

JavaScript

JavaScript

But it will works if you expect only one amount on list icl_dollar_amount_l. For more elements you would have to use rather for-loop and check every element separatelly

JavaScript

But frankly I don’t know why you don’t check it in first loop for link in url: when you have direct access to icl_dollar_amount and body

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement