-3

I am trying to pull the link for the latest droplist from https://www.supremecommunity.com/season/spring-summer2020/droplists/

If you right click on latest and click inspect, you see this:

That link will change every week, so I am trying to pull it from that page.

When I do

import requests
from bs4 import BeautifulSoup

url = "https://www.supremecommunity.com/season/spring-summer2020/droplists/"
r = requests.get(url)
soup = BeautifulSoup(r.text,"html.parser")
my_data = soup.find('div', attrs = {'id': 'box-latest'})

I get:

div class="col-sm-4 col-xs-12 app-lr-pad-2" id="box-latest">
<a class="block" href="/season/spring-summer2020/droplist/2020-03-26/">
<div class="feature feature-7 boxed text-center imagebg boxedred sc-app-boxlistitem" data-overlay="7">
<div class="empty-background-image-holder">
<img alt="background" src=""/>
</div>
<h2 class="pos-vertical-center">Latest</h2>
</div>
</a>
</div>

How can I just pull the "/season/spring-summer2020/droplist/2020-03-26/" part out?

TTV jokzyz
  • 349
  • 1
  • 3
  • 13

1 Answers1

0
import requests
from bs4 import BeautifulSoup

r = requests.get(
    "https://www.supremecommunity.com/season/spring-summer2020/droplists/")
soup = BeautifulSoup(r.content, "html.parser")


print(soup.find("div", id="box-latest").contents[1].get("href"))

Output:

/season/spring-summer2020/droplist/2020-03-26/
  • 2
    @TTVjokzyz you've to read [Markdown help](https://stackoverflow.com/editing-help) to understand how to post your question. And then you have to do some search before posting your question as it's completely a `duplicate` question. I've edited your question format to make it easier for viewers to read it. – αԋɱҽԃ αмєяιcαη Mar 26 '20 at 03:01