Python Forum
Get latest version off website and save it as variable [SOLVED]
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get latest version off website and save it as variable [SOLVED]
#3
(Nov-14-2021, 10:55 AM)snippsat Wrote: A more normal way is to web-scrape the info you want.
Example.
import requests
from bs4 import BeautifulSoup

url = 'https://gpac.wp.imt.fr/downloads/'
response = requests.get(url)
soup = BeautifulSoup(response.content, 'lxml')
print(soup.select_one('#post-147 > div > p:nth-child(3)').text)
# Just version
version = soup.select_one('#post-147 > div > p:nth-child(3) > strong').text
print(version)
Output:
The current GPAC release is 1.0.1 (released in September 2020). 1.0.1
This info #post-147 > div > p:nth-child(3) can just copy from Browser right click copy selector.
Then in BS use the CSS selector way with select or select_one.

Okay yeah that work's thanks.
I haven't understood how I can do it for other sites tho. For another example, how do I get the information for this site: https://www.makemkv.com/download/
Do I need to find out what CSS part I'm looking for using a browser?

Edit: Alright I got it (sorry getting it so late). My output is "#content > ul:nth-child(3) > li > a" and it prints "MakeMKV 1.16.5 for Windows". How do i cut it to only show the video? I didn't understand that in your part
Reply


Messages In This Thread
RE: Get latest version off website and save it as variable - by AlphaInc - Nov-14-2021, 08:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to save to multiple locations during save cubangt 1 601 Oct-23-2023, 10:16 PM
Last Post: deanhystad
  SOLVED variable as tuple name krayon70 7 1,903 Apr-09-2022, 03:30 PM
Last Post: krayon70
  How to save specific variable in for loop in to the database? ilknurg 1 1,190 Mar-09-2022, 10:32 PM
Last Post: cubangt
  [solved] subdictionaries path as variable paul18fr 4 2,719 May-18-2021, 08:12 AM
Last Post: DeaD_EyE
  [solved] Variable number of dictionnaries as argument in def() paul18fr 11 6,264 Apr-20-2021, 11:15 AM
Last Post: paul18fr
  Running latest Python version on the Terminal (MAC) Damian 4 2,686 Mar-22-2021, 07:58 AM
Last Post: Damian
  Latest file with a pattern produces an error tester_V 4 3,254 Dec-10-2020, 02:14 AM
Last Post: tester_V
  Read plotly-latest.min.js from local issac_n 1 2,231 Nov-18-2020, 02:08 PM
Last Post: issac_n
  How to save latest time stamp in a file? redwood 12 7,386 Jul-11-2019, 11:03 AM
Last Post: redwood
  Python ftp server get the latest sub-directory name muzamalrana 1 3,506 Aug-08-2018, 11:40 PM
Last Post: muzamalrana

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020