Answer the question
In order to leave comments, you need to log in
How to search for multiple classes in a tag, search by css selector and xpath?
Good afternoon, Parsing Medium and difficulties arose in this matter.
What do I use
from selenium import webdriver
import requests
def md():
url = 'https://medium.com/@Tacenda/the-universe-is-all-of-space-and-time-spacetime-and-its-contents-9-which-includes-planets-3c9a58475b14'
driver = webdriver.PhantomJS(executable_path='/usr/local/lib/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs')
driver.get(url)
driver.implicitly_wait(5)
# avatar = driver.find_element_by_css_selector('#_obv\2e shell\2e _surface_1498118264269 > div > main > article > footer > div.u-padding0.u-clearfix.u-backgroundGrayLightest.u-print-hide.supplementalPostContent.js-responsesWrapper > div > div > div.responsesStream.js-responsesStream > div > div > div > div > div.u-clearfix.u-marginBottom10 > div > div > div.postMetaInline-avatar.u-flex0 > a')
# avatar = driver.find_element_by_xpath('//*[@id="_obv.shell._surface_1498118264269"]/div/main/article/footer/div[5]/div/div/div[4]/div/div/div/div/div[1]/div/div/div[1]/a')
# avatar = driver.find_elements_by_class_name('link avatar u-baseColor--link')
avatar = driver.find_elements_by_class_name('link')
print([i.text for i in avatar])
md()
'link avatar u-baseColor--link' in driver.page_source
<a class="link avatar u-baseColor--link" href="https://medium.com/@Tacenda" data-action="show-user-card" data-action-value="17f98bbae51d" data-action-type="hover" data-user-id="17f98bbae51d" dir="auto"><img src="https://cdn-images-1.medium.com/fit/c/36/36/1*Jtm9sTbkCLI_0A0AadvVzw.jpeg" class="avatar-image u-size36x36 u-xs-size32x32" alt="Go to the profile of Adriano Celentano"></a>
Answer the question
In order to leave comments, you need to log in
.link.avatar.u-baseColor--link
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question