I'm using Selenium and Beautiful Soup.
I want to retrieve URL4 as there is a description. Therefore, I did the following.
driver = webdriver.Chrome (r "\ chromedriver.exe") html = driver.page_source.encode ('utf-8') soup = BeautifulSoup (html, "html.parser") Murl =  for f in soup.find_all ('a'): if f.getText () == "search character": Murl.append (f) Print (Murl) NextURL = str (Murl  .get ('href'))
All the ones with a tag are included in Murl.
I ran it once, checked the print, and selected it from the a tags (in this case, it was the second one, so I chose Murl ) to extract the URL.
For the time being, it can be used with this, but to retrieve the URL in the href, there is no statement that can be made a little easier, such as using a for statement or if statement, and then extracting the contents of the href attribute. I wondered if I could make it simple.
I would be grateful if you could give us your opinion that this is easier or something like this.
Answer # 1
Murl = soup.find_all ('a', text ='search string') NextURL = str (Murl  .get ('href'))
I didn't have to use for loops or if statements like this.
Answer # 2
I don't think this is what you are looking for,
For the time being, in the inclusion notation.
Murl = [f for f in soup.find_all ('a') if f.getText () == "search character"]
- i want to convert "array string" to an array in python
- python - session, login to website by guessing cookies
- i want to aggregate a specific character string by day using the python groupby count function etc
- python - sum of numbers by inputting a character string
- python 3x - i want to be able to run a scraping program created in python on a website
- i want to extract one character string of text that exists in multiple files with python
- [python] how to search for data close to a query from 2d distribution data
- website button clicks in selenium and python
- i want to extract specific information from a python string
- python - i want to search only a part of html (a certain selector) with find_all of beautifulsoup
- i want to change a string to hexadecimal in python
- get and list article links and article titles on your website using python
- python - i want to search for a specific value in a row specified by a two-dimensional array
- i want to change the 24:00 python pandas string to 00:00 the next day
- google apps script - how to make the string search in gas case insensitive
- if a specific word is described in the python string, set a flag and repeat it multiple times
- i want to delete a specific word from a string using a regular expression python
- i want to extract the date and time from a string in python
- python 3x - i want to find out if there is a specific hiragana in the string
- python : How to display media files loaded through the admin. Panel in Django?
- python : Creating an aggregator site
- python : Not displayed Radio Points written using Django templates
- Authorization of the session through Python without Name tag
- python : Parsing Email Addresses from Web Page Text
- python : How to make the default item in select
- python : CSS Connection Problems
- How to edit a json file via SSH on a server using Python and display data on the HTML site?
- How to send a link to a file via a variable in the SRC attribute IMG tag in a piece of HTML code on Python?