1

i've aready got the sub link on the homepage. But try to take title for each sub link. Can anyone help me! thanks you!

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

tem_data = {'URL':[],  #make database,
           'Title':[]}

driver = webdriver.Edge()
driver.get("https://m.cafe.naver.com/ca-fe/minivelobike")
URL = ([my_elem.get_attribute("href") for my_elem in WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.XPATH, "//a[@class='txt_area' and @href]")))])

Title = "some code to get 'tit"  #get title of each URL[enter image description here][1]

tem_data['URL'].append(URL)
tem_data['Title'].append(Title)
print(tem_data)

Keyword_seach=('xxx.db')
  • you should refer this [question](https://stackoverflow.com/questions/62146031/how-to-extract-href-link-title-with-selenium) – Devam Sanghvi Apr 16 '22 at 05:09
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Apr 17 '22 at 10:26

1 Answers1

0

The below should get you the titles:

Title = [my_elem.text for my_elem in driver.find_elements(By.CSS_SELECTOR, "strong.tit")]

The thing about Korean characters is that if you want to view them in your terminal, you will need to set your output encoding to UTF-8:

import sys
sys.stdout.reconfigure(encoding='utf-8')
print(tem_data['Title'])
Duc Nguyen
  • 301
  • 2
  • 8