Showing posts with label Web Crawling. Show all posts
Showing posts with label Web Crawling. Show all posts

Saturday, June 20, 2015

Scraping List of all Mangas with Link in Python

Snapshot of a text file saved under the comma-...
Snapshot of a text file saved under the comma-separated value format (Photo credit: Wikipedia)
I wrote a little script that scrapes all the Manga names and their respective homepage URLs as a CSV file.

Here's the code :-

from lxml.html import parse

__author__ = 'Psycho_Coder'


def main():
    with open("mangalist.csv", "w") as f:
        tree = parse("http://www.mangapanda.com/alphabetical")
        manga_name_list = tree.xpath("//ul[@class='series_alpha']/li/a/text()")
        manga_url_list = tree.xpath("//ul[@class='series_alpha']/li/a/@href")
        f.write("\"Manga Name\", URL\n")

        for i in range(len(manga_name_list)):
            f.write("\"{0}\", http://www.mangapanda.com{1}\n".format(manga_name_list[i].replace("\"", ""), manga_url_list[i]))

if __name__ == "__main__":
    main() 

CSV : https://github.com/AnimeshShaw/MangaScrapper/blob/master/resources/mangalist.csv
Code On Github https://github.com/AnimeshShaw/MangaScrapper/blob/master/resources/MangaList.py


I hope you liked this script. Please share this post in your social network :)

Continue Reading →

Wednesday, June 17, 2015

Crawling Net-Security.org Archive Magazines using Python

English: A candidate icon for Portal:Computer ...
English: A candidate icon for Portal:Computer security (Photo credit: Wikipedia)
(IN)SECURE Magazine is a free digital security publication discussing some of the hottest information security topics. I wrote to code to download all the magazines, save then in a folder and then create an archive of the folder. Manually downloading them is boring and I am lazy enough to avoid getting my hands on them. So I wrote a little code which does the work for me. I will be crawling all the mags from this page. For the purpose of crawling I used requests and lxml libraries and so if you're using this code make sure you install these two packages using pip.

Without further adieu, I will give you he code now. 



Working Screenshot


[Image: UzQDtRP.png]



Continue Reading →

Follow Me!

Followers

Visitor Map