Python Forum
Beautifulsoup and JavaScript Values
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Beautifulsoup and JavaScript Values
#3
Here it is:
import requests
import urllib.request
import time
from bs4 import BeautifulSoup
import os

if __name__ == '__main__':
    def dossier():
        os.chdir("C://Users//Ridha//Desktop//Web-Scrapper")

    dossier()
moit="https://www.lelscan-vf.com/manga/"
url="https://www.lelscan-vf.com/manga/vinland-saga/164"


def Navigate(url):
    response = requests.get(url)
    soup = BeautifulSoup(response.text, "html.parser")
    L= Img(soup)
    return soup

def Img(soup):
    L = []
    images = soup.findAll('img')
    for lien in images:
        if 'class' in lien.attrs:
            if lien['class']==['img-responsive']:
                a= lien['data-src']
                L.append(a)
    return L
def Next(soup):

    a= soup.find('var next_chapter')
    NextUrl = a['var next_chapter']
     if NextUrl==""
    NextUrl="End"
    else:
    NextUrl=a['var next_chapter']
   
   
    return NextUrl
If you want to try the code , just type in the console Navigate("https://www.lelscan-vf.com/manga/vinland-saga/164"
)
It ll give you the soup. And in the soup is the variable. I would like to get it and return it. Thanks for helping mate
Reply


Messages In This Thread
Beautifulsoup and JavaScript Values - by Reldaing - Feb-22-2020, 11:58 PM
RE: Beautifulsoup and JavaScript Values - by Reldaing - Feb-23-2020, 01:15 AM

Forum Jump:

User Panel Messages

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