I getting names & telephone numbers from a website with python
def listToString(s): str1 = "" for ele in s: str1 += ele + "\n\n" return str1 elem = driver.find_elements_by_xpath("//span[@class='showLink reveal']") for element in elem: element.click() name = driver.find_elements_by_xpath("//span[@itemprop='name']") names = [elem.get_attribute('innerHTML') for elem in name] print(listToString(names)) mobile = driver.find_elements_by_xpath("//a[@style='display:inline']") mobiles = [elem.get_attribute('href') for elem in mobile] print(listToString(mobiles)) This is displays the names & phone numbers but the output is:
name: xyz name: xyz name: xyz tel: +12345678910 tel: +12345678910 tel: +12345678910 How can I do that the output will be a name and then a phone number like this:
name: xyz tel: +12345678910 name: xyz tel: +12345678910 name: xyz tel: +12345678910 https://stackoverflow.com/questions/66837480/selenium-how-to-display-specified-string-under-another-specified-string March 28, 2021 at 08:47AM
没有评论:
发表评论