I am trying to get names of the songs from this site https://pagalworld.me/category/11598/Latest%20Bollywood%20Hindi%20Mp3%20Songs%20-%202017.html using link extractor but the results are repeating.
import scrapy
from scrapy import Request
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import CrawlSpider, Rule
class RedditSpider(CrawlSpider):
name='pagalworld'
allowed_domains = ["pagalworld.me"]
start_urls=['https://pagalworld.me/category/11598/Latest%20Bollywood%20Hindi%20Mp3%20Songs%20-%202017.html']
rules = (
Rule(
LinkExtractor(restrict_xpaths='//div/ul'),
follow=True,
callback='parse_start_url'),
)
def parse_start_url(self, response):
songName= response.xpath('//li/b/a/text()').extract()
for item in songName:
yield {"songName":item,
"URL":resposne}
Everything seems to be correct with your spider. However if you look at the song page it offers two versions of each song:
One version is lower 190kbps quality and the other is higher 320kbps quality.
In this you probably want just to keep one of those:
Edit: Seems like there are also duplication issues. Try disabling
follow=True
on your link extractor since in this case you don't want to follow.