| ########################################################## | |
| # Scrapy template modified by: | |
| # * Nicolas Felipe Trujillo Montero | |
| ########################################################## | |
| # Needed Libraries | |
| import scrapy | |
| class MyanimelistScrappingSpider(scrapy.Spider): | |
| # Class Attributes | |
| name = "myanimelist_scrapping" | |
| allowed_domains = ["myanimelist.net"] | |
| start_urls = ["https://myanimelist.net/anime/" + str(x) + "" for x in range(0,10000)] | |
| def parse(self, response): | |
| path_title = "div > div.h1.edit-info > div.h1-title > div > h1.title-name.h1_bold_none > strong::text" | |
| path_synopsis = "div#content > table > tr > td > div.rightside.js-scrollfix-bottom-rel > table > tr > td > p" | |
| for anime_info in response.css("div#myanimelist > div.wrapper > div#contentWrapper"): | |
| try: | |
| title = anime_info.css(path_title).get() | |
| # print(title) | |
| except: | |
| title = None | |
| try: | |
| synopsis = anime_info.css(path_synopsis).get() \ | |
| .replace("""<p itemprop="description">""", '') \ | |
| .replace("\n", "") \ | |
| .replace("</br>","") \ | |
| .replace("</p>","") \ | |
| .replace("[Written by MAL Rewrite]","") \ | |
| .replace("<br>",'') | |
| synopsis_ar = synopsis.splitlines() | |
| aux = [] | |
| for _str in synopsis_ar: | |
| if _str != "": | |
| aux.append(_str) | |
| synopsis_ar = aux | |
| # print(synopsis_ar) | |
| except Exception as e: | |
| # print(e) | |
| synopsis = None | |
| yield{ | |
| "Title": title, | |
| "Synopsis": synopsis_ar | |
| } | |
| """ | |
| yield{ | |
| "Title": title, | |
| "Genre": genre_total, | |
| "Source_&_Year": year, | |
| "Status": status, | |
| "Number_eps": number_eps, | |
| "Duration_each_ep": duration_each_ep, | |
| "Score": score, | |
| "Members": members, | |
| "Studio": studio, | |
| "Link": url | |
| } | |
| """ |