Seowoo Jang
Seowoo Jang

Reputation: 65

How can I extract a data from one tag when there are more same type of tag around

I am practicing about web-scraping with Python.

And I have a problem because of the structure of webpage.

enter image description here

There are two <a> in same list class.

I want to extract just link of the post. And I want to know how can I extract this link without touching another one.

Now, I write the code like this:

def extract_job(post):
    title = post.find("span", {"class": "title"})
    company = post.find("span", {"class": "company"})
    location = post.find("span", {"class": "region"})
    link = post.find

What do I have to put after find function?

Upvotes: 0

Views: 71

Answers (1)

superepicprogrammer
superepicprogrammer

Reputation: 83

Instead of using the find method you can do it using css selectors with the select method. In the inspector if you right click on the element you want to find the selector for and click copy selector you can copy the selector and use that in your code.

link = post.select(put the copied selector here)

Upvotes: 1

Related Questions