#๐Ÿ”’ URGENT webscraping help -beautifulsoup

7 messages ยท Page 1 of 1 (latest)

leaden crestBOT
#

@shrewd breach

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

shrewd breach
#
response = requests.get(overview_url)
if response.status_code == 200:
            soup = BeautifulSoup(response.text, 'html.parser')
            soup.prettify()
            details = soup.find('div', class_= "pd_content")
            #print(soup.select_one("span[title=Age]").text)
            if details:
                print("YES")
                pd_left = details.find('ul', class_='pd_left')
                if pd_left:
                    print(f"{pd_left}")
                    list_item = pd_left.find('li')
                    if list_item:
                        # Find the anchor tag within the list element
                        spans = list_item.find_all('span')
                        print(spans)
                        # Check if there are at least two spans
                        if len(spans) >= 2:
                            # Get the second span and its text content
                            second_span_value = spans[1].text.strip()
                            print(f"Value of the second span: {second_span_value}")  # Prints "36 (1987.05.22)"
    
#<span>21 (2002.11.16)</span>
            else: 
                    print(f"  details  not found")#DOB: {dob}
            #else:
                #print(f"atp_player-personaldetails not found ")
    else: print("No response")
#

output

https://www.atptour.com/en/players/zsombor-velcz/v0e1/overview
YES
<ul class="pd_left">
<li v-if="playerDetails.Active.Id == 'I'">
<span>DOB</span>
<span>{{formatDate(playerDetails.BirthDate)}}</span>
</li>
<li v-else="">
<span>Age</span>
<span>{{playerDetails.Age}} ({{formatDate(playerDetails.BirthDate)}})</span>
</li>
<li>
<span>Weight</span>
<span>{{playerDetails.WeightLb}} lbs ({{playerDetails.WeightKg}}kg)</span>
</li>
<li>
<span>Height</span>
<span>{{playerDetails.HeightFt}} ({{playerDetails.HeightCm}}cm)</span>
</li>
<li>
<span>Turned pro</span>
<span>{{playerDetails.ProYear}}</span>
</li>
</ul>
[<span>DOB</span>, <span>{{formatDate(playerDetails.BirthDate)}}</span>]

astral rivet
#

and so what do you need help with

#

theres guide on how to use beatiful soup for web scraping

leaden crestBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.