Python Forum
[split] [Help] Keep getting a 'TypeError' from Django and BeautifulSoup
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] [Help] Keep getting a 'TypeError' from Django and BeautifulSoup
Hi. I am also new to Django. I want to do the same as you scrape using Django as a web application. the code right now working fine using python3 Jupyter notebook.

import requests
import json
import time
from bs4 import BeautifulSoup as soup

def getLi(text):
    for i in x: 
        if i[0] == "i" and i[1:].isdigit():
            return (i.replace("i",""))
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36'}

count = 0
link = input("Please enter url to scrape ")
x = link.split("-")
d = soup(requests.get(link).text, 'html.parser')
results = list(map(int, filter(None, [i.text for i in d.find_all('button', {'class':'next-pagination-item'})])))
print (results)
for i in range(min(results), max(results)+1):
    time.sleep(10)  #0.5 * random.random()
    url = (''
    req = requests.get(url,headers=headers)
    data = req.json()
    for i in data['model']['items']:
        reviewContent = i['reviewContent']
where should I put this code? right? what should I put at and templates folder that contain HTML. Huh Huh

Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeError: missing 1 required positional argument (word counter Django app) Drone4four 2 11,694 Jul-11-2019, 09:34 PM
Last Post: Drone4four
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 1,683 Jun-30-2019, 12:21 AM
Last Post: scidam
  [Help] Keep getting a 'TypeError' from Django and BeautifulSoup Plant_Boy 7 3,764 Jun-13-2018, 04:13 PM
Last Post: Larz60+
  How to create dynamic webscraper in Django using BeautifulSoup Prince_Bhatia 1 4,906 Jan-26-2018, 02:07 PM
Last Post: frostbite

Forum Jump:

User Panel Messages

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