jcavecilla commited on
Commit
f9d4c61
1 Parent(s): 1ca9461

Upload myanimelist_scrapy.py

Browse files
Files changed (1) hide show
  1. myanimelist_scrapy.py +78 -0
myanimelist_scrapy.py ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##########################################################
2
+ # Scrapy template modified by:
3
+ # * Nicolas Felipe Trujillo Montero
4
+ ##########################################################
5
+
6
+ # Needed Libraries
7
+ import scrapy
8
+
9
+ class MyanimelistScrappingSpider(scrapy.Spider):
10
+
11
+ # Class Attributes
12
+ name = "myanimelist_scrapping"
13
+ allowed_domains = ["myanimelist.net"]
14
+ start_urls = ["https://myanimelist.net/anime/" + str(x) + "" for x in range(0,10000)]
15
+
16
+ def parse(self, response):
17
+
18
+ path_title = "div > div.h1.edit-info > div.h1-title > div > h1.title-name.h1_bold_none > strong::text"
19
+
20
+ path_synopsis = "div#content > table > tr > td > div.rightside.js-scrollfix-bottom-rel > table > tr > td > p"
21
+
22
+ for anime_info in response.css("div#myanimelist > div.wrapper > div#contentWrapper"):
23
+
24
+ try:
25
+
26
+ title = anime_info.css(path_title).get()
27
+ # print(title)
28
+
29
+ except:
30
+
31
+ title = None
32
+
33
+ try:
34
+
35
+ synopsis = anime_info.css(path_synopsis).get() \
36
+ .replace("""<p itemprop="description">""", '') \
37
+ .replace("\n", "") \
38
+ .replace("</br>","") \
39
+ .replace("</p>","") \
40
+ .replace("[Written by MAL Rewrite]","") \
41
+ .replace("<br>",'')
42
+
43
+ synopsis_ar = synopsis.splitlines()
44
+
45
+ aux = []
46
+ for _str in synopsis_ar:
47
+ if _str != "":
48
+ aux.append(_str)
49
+
50
+ synopsis_ar = aux
51
+ # print(synopsis_ar)
52
+
53
+ except Exception as e:
54
+
55
+ # print(e)
56
+ synopsis = None
57
+
58
+
59
+
60
+
61
+ yield{
62
+ "Title": title,
63
+ "Synopsis": synopsis_ar
64
+ }
65
+ """
66
+ yield{
67
+ "Title": title,
68
+ "Genre": genre_total,
69
+ "Source_&_Year": year,
70
+ "Status": status,
71
+ "Number_eps": number_eps,
72
+ "Duration_each_ep": duration_each_ep,
73
+ "Score": score,
74
+ "Members": members,
75
+ "Studio": studio,
76
+ "Link": url
77
+ }
78
+ """