File tree 2 files changed +10
-15
lines changed
2 files changed +10
-15
lines changed Original file line number Diff line number Diff line change @@ -8,22 +8,17 @@ To run this:
8
8
**Output:**
9
9
```
10
10
Title: Me at the zoo
11
- Views: 106602383
12
- Published at: 23/04/ 2005
11
+ Views: 172639597
12
+ Published at: 2005-04-23
13
13
Video Duration: 0:18
14
14
Video tags: me at the zoo, jawed karim, first youtube video
15
- Likes: 3825489
16
- Dislikes: 111818
15
+ Likes: 8188077
16
+ Dislikes: 191986
17
17
18
- Description: The first video on YouTube. Maybe it's time to go back to the zoo?
19
-
20
- NEW VIDEO LIVE! https://www.youtube.com/watch?v=dQw4w...
21
-
22
-
23
- == Ok, new video as soon as 10M subscriberz! ==
18
+ Description: The first video on YouTube. While you wait for Part 2, listen to this great song: https://www.youtube.com/watch?v=zj82_v2R6ts
24
19
25
20
26
21
Channel Name: jawed
27
22
Channel URL: https://www.youtube.com/channel/UC4QobU6STFB0P71PMvOGN5A
28
- Channel Subscribers: 1.03M
23
+ Channel Subscribers: 1.98M subscribers
29
24
```
Original file line number Diff line number Diff line change @@ -16,13 +16,13 @@ def get_video_info(url):
16
16
# initialize the result
17
17
result = {}
18
18
# video title
19
- result ["title" ] = soup .find ("h1" ). text . strip ()
19
+ result ["title" ] = soup .find ("meta" , itemprop = "name" )[ 'content' ]
20
20
# video views (converted to integer)
21
- result ["views" ] = int ( '' . join ([ c for c in soup .find ("span " , attrs = { "class" : "view-count" }). text if c . isdigit () ]))
21
+ result ["views" ] = soup .find ("meta " , itemprop = "interactionCount" )[ 'content' ]
22
22
# video description
23
- result ["description" ] = soup .find ("yt-formatted-string " , { "class" : "content" }). text
23
+ result ["description" ] = soup .find ("meta " , itemprop = "description" )[ 'content' ]
24
24
# date published
25
- result ["date_published" ] = soup .find ("div " , { "id" : "date" }). text [ 1 : ]
25
+ result ["date_published" ] = soup .find ("meta " , itemprop = "datePublished" )[ 'content' ]
26
26
# get the duration of the video
27
27
result ["duration" ] = soup .find ("span" , {"class" : "ytp-time-duration" }).text
28
28
# get the video tags
You can’t perform that action at this time.
0 commit comments