Created
January 12, 2023 06:01
-
-
Save Kd-Here/9b813477c4b2ba3bd22acaa3c995f3bc to your computer and use it in GitHub Desktop.
Created a book which can scrap all the data from wesite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import requests | |
import time | |
import datetime | |
import csv | |
Movies_list = requests.get('https://subslikescript.com/movies').text | |
soup1 = BeautifulSoup(Movies_list,'lxml') | |
a = (soup1.find('a',class_='page-link').get('href')) | |
print(a) | |
def fun(link): | |
m = requests.get(link).text | |
soup = BeautifulSoup(m,'lxml') | |
for word in soup.find_all('a'): | |
if word.li != None: | |
movieslist = (word.li.text) | |
with open('Movies_List.txt','+a',encoding='utf-8') as file: | |
file.write(movieslist) | |
file.write("\n") | |
next_pg_link = (soup.find('a',class_='page-link',rel= 'next').get('href')) | |
print(next_pg_link) | |
return (next_pg_link) | |
c = fun(a) | |
for i in range(5): | |
c = fun(c) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment