0

I want to get some links in the url but they I get all links instead. How can I pull the links by specifying the selector?

For ex:

I'm using:

ids = browser.find_elements_by_xpath('//a[@href]')
for ii in ids:
print(ii.get_attribute('href'))

Result: All Links

But I want just some selector

<a class="classifiedTitle" title="MONSTER TULPAR T5V13.1+ 15,6 EKRAN+İ7+6GB GTX1060+16RAM+256GB SS" href="/ilan/ikinci-el-ve-sifir-alisveris-bilgisayar-dizustu-notebook-monster-tulpar-t5v13.1-plus-15%2C6-ekran-plusi7-plus6gb-gtx1060-plus16ram-plus256gb-ss-793070526/detay">
MONSTER TULPAR T5V13.1+ 15,6 EKRAN+İ7+6GB GTX1060+16RAM+256GB SS</a>

enter image description here

So how can I add some selectors?

Thanks & Regards

0buz
  • 3,443
  • 2
  • 8
  • 29
x-Palace
  • 43
  • 7
  • I think [this](https://stackoverflow.com/questions/1006283/how-to-select-the-first-element-with-a-specific-attribute-using-xpath) should answer your question – vi_ral Apr 03 '20 at 14:58

2 Answers2

0

If you want just the item in your example:

href=browser.find_element_by_xpath("//a[@title='MONSTER TULPAR T5V13.1+ 15,6 EKRAN+İ7+6GB GTX1060+16RAM+256GB SS" href="/ilan/ikinci-el-ve-sifir-alisveris-bilgisayar-dizustu-notebook-monster-tulpar-t5v13.1-plus-15%2C6-ekran-plusi7-plus6gb-gtx1060-plus16ram-plus256gb-ss-793070526/detay']").get_attribute('href')

There are obviously more than one way of identifying your element, this is simply an example using xpath.

0buz
  • 3,443
  • 2
  • 8
  • 29
0

Try the following css selector to get the specific link.

print(browser.find_element_by_css_selector("a.classifiedTitle[title='MONSTER TULPAR T5V13.1+ 15,6 EKRAN+İ7+6GB GTX1060+16RAM+256GB SS'][href*='/ilan/ikinci-el-ve-sifir-alisveris-bilgisayar-dizustu-notebook-monster-tulpar-']").get_attribute("href"))
KunduK
  • 32,888
  • 5
  • 17
  • 41