pycharmの開発環境で、フレームワークのscrapyを学習中です。
以下のようなサンプルコードを書きましたが、pycharmのコード補完が利かなかったので・・・
python
1import scrapy 2 3class BlogSpider(scrapy.Spider): 4 name = 'blogspider' 5 start_urls = ['https://blog.xxxxxx.com'] 6 7 def parse(self, response): 8 for url in response.css('option::attr("value")').re(r'.*/[0-9]{4}/[0-9]{2}/.*'): 9 yield scrapy.Request(response.urljoin(url), self.parse_titles) 10 11 def parse_titles(self, response): 12 for post_title in response.css('h2.entry-title > a::text').extract(): 13 yield {'title': post_title} 14
def parse(self, response):
はscrapy.Spider
を継承し、メソッドのオーバーライドをしましたが
このresponse
という引数に対して、コード補完を利かせたいです。
また、以下の場合も
python
1import lxml.html 2 3tree = lxml.html.parse('index.html') 4html = tree.getroot()
lxml.html.parse('index.html')
と入力するときはコード補完はされるのですが
その戻り値でtree.getroot()
の部分ではコード補完ができませんでした
外部ライブラリなどに対しては、そのライブラリ側で何らかの対応がされていないと
コード補完は行われないのでしょうか?
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2017/10/12 15:01