Skip to content

Commit 2ccad19

Browse files
committed
topic_vote default to 0,topic_click_count to -1
1 parent 6a2dd76 commit 2ccad19

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

v2ex_scrapy/v2ex_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ def parse_topic(response: scrapy.http.response.html.HtmlResponse, topic_id):
5959
topic_node = response.css(".header > a:nth-child(4)::attr(href)").re_first(
6060
r"\/(\w+)$", ""
6161
)
62-
topic_click_count = response.css(".header > small::text").re_first(r"\d+", "0")
62+
topic_click_count = response.css(".header > small::text").re_first(r"\d+", "-1")
6363
topic_tags = response.css(".tag::attr(href)").re(r"/tag/(.*)")
64-
topic_vote = response.xpath('(//a[@class="vote"])[1]/text()').re_first(r"\d+", "-1")
65-
# need login
64+
topic_vote = response.xpath('(//a[@class="vote"])[1]/text()').re_first(r"\d+", "0")
65+
# need login, some topics may not have this
6666
topic_favorite_count = -1
6767
topic_thank_count = -1
6868
topic_stats = response.css(".topic_stats::text").re(r"\d+")

0 commit comments

Comments
 (0)