import scrapy import re import pickle import json import sys class MySpider(scrapy.Spider): global allUrlFile , fullUrl allUrlFile = open ( 'allUrl.txt' , 'a' ) fullUrl = open ( 'fullUrl.txt' , 'a' ) localHost = "http://localhost:8050/render.html?url=" #youtubeUrl = "https://www.youtube.com/channel/UCv1Ybb65DkQmokXqfJn0Eig/channels" # channel with only one ajax # youtubeUrl = "https://www.youtube.com/user/khanacademy/videos" # khan academy youtubeUrl = "https://www.youtube.com/channel/UCU0kWLAbhVGxXarmE3b8rHg/videos" # khan hindi start_urls = [localHost + youtubeUrl] name = "allvideos" def start_requests( self ): for url in self .start_urls: yield scrapy.Request(url, self .parse) def parse( self , response): self .log( "this program just visited " + response.url) if not 'browse_ajax' in response.url: ...