2

Python3 とパッケージリクエストを使用して HTML データを取得しています。

ラインを走らせてみました

r = requests.get('https://github.com/timeline.json')

、これはチュートリアルの例ですが、役に立ちません。ただし、実行すると

request = requests.get('http://www.math.ksu.edu/events/grad_conf_2013/')

それは正常に動作します。次のようなエラーが発生しています

AttributeError: 'MockRequest' object has no attribute 'unverifiable' 
Error in sys.excepthook:

動作している html ページは私が書いた基本的な html であるため、取得しようとしている Web ページのタイプにエラーが関係していると考えています。

私はリクエストとPython全般に非常に慣れていません。私はスタックオーバーフローも初めてです。

4

1 に答える 1

0

ちょっとした例として、Web サイト (この場合は IP) からデータを取得して表示するために私が開発した小さなツールを次に示します。

# Import the requests module
# TODO: Make sure to install it first
import requests

# Get the raw information from the website
r = requests.get('http://whatismyipaddress.com')
raw_page_source_list = r.text
text = ''

# Join the whole list into a single string in order
# to simplify things
text = text.join(raw_page_source_list)

# Get the exact starting position of the IP address string
ip_text_pos = text.find('IP Information') + 62

# Now extract the IP address and store it
ip_address = text[ip_text_pos : ip_text_pos + 12]

# print 'Your IP address is: %s' % ip_address
#           or, for Python 3 ...            #
# print('Your IP address is: %s' % ip_address)
于 2013-05-09T06:56:51.547 に答える