Project - Extract Data [free code include]

Soldato
Joined
9 Dec 2006
Posts
9,292
Location
@ManCave
Hi all,

So, i'm working on a project (most likely in python 3)
to create a way to "PLAY ALL" from video found in your you-tube subscriptions "https://www.youtube.com/feed/subscriptions"

currently you have add them to playlist to do this or use a third party (which may or may not be secure)


one method idea of this project was to use a html parser
for my first test i used OCUK for this week only

Output
Code:
8Pack

Team Group Dark Pro " Edition" 16GB (2x8GB) DDR4 PC4-25600C14 3200MHz Dual Channel Kit - Black/
Was: £188.99 NOW:£169.99



Team Group

Vulcan T-Force 8GB (2x4GB) DDR4 PC4-24000C16 3000MHz Dual Channel Kit - Grey (TLGD48G3000
Was: £59.99 NOW:£52.99



Samsung

970 EVO Polaris 250GB M.2 2280 PCI-e 3.0 x4 NVMe Solid State Drive
Was: £74.99 NOW:£68.99



Samsung

1TB 860 EVO SSD 2.5" SATA 6Gbps 64 Layer 3D V-NAND Solid State Drive (MZ-76E1T0B/EU)
Was: £179.99 NOW:£139.99



Python code if you wish to use for yourself
Code:
import requests
from bs4 import BeautifulSoup

page = requests.get("https://www.overclockers.co.uk/this-week-only")
soup = BeautifulSoup(page.content, 'html.parser')

innercontent = soup.find(id="content")
items = innercontent.find_all(class_="producttitles")
value = innercontent.find_all(class_="pseudoprice")


for index in (range(len(items))):
    OEM = items[index].find(class_="ProductSubTitle").get_text()
    description = items[index].find(class_="ProductTitle").get_text()
    wasprice = value[index].find(class_="pseudo").get_text()
    price = value[index].find(class_="price").get_text()

    print("%s%s%sNOW:%s\n\n" % (OEM, description, wasprice, price))
 
Looks good. There's an RSS feed for this-week-only deals:
https://www.overclockers.co.uk/this-week-only?sRss=1
That would probably be easier to use but I know you're just doing it as a test for youtube.
There's also some sort of xml file output available for your youtube subscriptions I think.

edit: found it. go to https://www.youtube.com/subscription_manager and scroll to the bottom of the page. There's a button "Export Subscriptions" which gives you an xml file with links to each of your subscribed channel's RSS feeds. You'd just need to iterate through each of the links and read each RSS feed to get a list of videos for all subscriptions.

That's what these types of feed are designed for and it's much more reliable to use them. The format will never change whereas if they update the layout on the main HTML site it could stop your code from working.
 
Last edited:
cheers, that was my plan, not sure how i'm going to tackle the making the playlist part yet. might be able to send a curl request to youtube to add it to a playlist maybe....

i don't want to involve user/passwords i want to let chrome do that so that it "just works"
 
Back
Top Bottom