teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

エラーメッセージ全文を追記しました。

2019/03/15 04:49

投稿

MacKimura
MacKimura

スコア15

title CHANGED
File without changes
body CHANGED
@@ -58,4 +58,78 @@
58
58
  filename = "filename.csv"
59
59
  search_results_df.to_csv(filename, encoding = "utf-8-sig") # encoding指定しないと、エラーが発生します。
60
60
  files.download(filename)
61
- ```
61
+ ```
62
+
63
+
64
+ ### エラーメッセージ
65
+
66
+ EVgo: Electric Vehicle (EV) Charging Stations | EV Fast Charging
67
+ Charge!!!
68
+ PlugShare - EV Charging Station Map - Find a place to charge your ...News for EV charge
69
+
70
+ ---------------------------------------------------------------------------
71
+ MissingSchema Traceback (most recent call last)
72
+ <ipython-input-20-932ef3fb8f3f> in <module>()
73
+ 44
74
+ 45 keyword = "EV charge"
75
+ ---> 46 search_results_df = get_search_results_df(keyword)
76
+ 47 search_results_df.head(10)
77
+ 48
78
+
79
+ <ipython-input-20-932ef3fb8f3f> in get_search_results_df(keyword)
80
+ 17 print(title)
81
+ 18 url = query_string_remove(tag.select("a")[0].get("href").replace("/url?q=",""))
82
+ ---> 19 affiliate_url = get_a8_links(url) # 作成したコードの追加
83
+ 20 se = pd.Series([rank, title, url, affiliate_url], columns)
84
+ 21 df = df.append(se, ignore_index=True)
85
+
86
+ <ipython-input-20-932ef3fb8f3f> in get_a8_links(url)
87
+ 25
88
+ 26 def get_a8_links(url):
89
+ ---> 27 html_doc = requests.get(url).text
90
+ 28 soup = BeautifulSoup(html_doc, 'html.parser')
91
+ 29 tags = soup.select("a")
92
+
93
+ /usr/local/lib/python3.6/dist-packages/requests/api.py in get(url, params, **kwargs)
94
+ 70
95
+ 71 kwargs.setdefault('allow_redirects', True)
96
+ ---> 72 return request('get', url, params=params, **kwargs)
97
+ 73
98
+ 74
99
+
100
+ /usr/local/lib/python3.6/dist-packages/requests/api.py in request(method, url, **kwargs)
101
+ 56 # cases, and look like a memory leak in others.
102
+ 57 with sessions.Session() as session:
103
+ ---> 58 return session.request(method=method, url=url, **kwargs)
104
+ 59
105
+ 60
106
+
107
+ /usr/local/lib/python3.6/dist-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
108
+ 492 hooks=hooks,
109
+ 493 )
110
+ --> 494 prep = self.prepare_request(req)
111
+ 495
112
+ 496 proxies = proxies or {}
113
+
114
+ /usr/local/lib/python3.6/dist-packages/requests/sessions.py in prepare_request(self, request)
115
+ 435 auth=merge_setting(auth, self.auth),
116
+ 436 cookies=merged_cookies,
117
+ --> 437 hooks=merge_hooks(request.hooks, self.hooks),
118
+ 438 )
119
+ 439 return p
120
+
121
+ /usr/local/lib/python3.6/dist-packages/requests/models.py in prepare(self, method, url, headers, files, data, params, auth, cookies, hooks, json)
122
+ 303
123
+ 304 self.prepare_method(method)
124
+ --> 305 self.prepare_url(url, params)
125
+ 306 self.prepare_headers(headers)
126
+ 307 self.prepare_cookies(cookies)
127
+
128
+ /usr/local/lib/python3.6/dist-packages/requests/models.py in prepare_url(self, url, params)
129
+ 377 error = error.format(to_native_string(url, 'utf8'))
130
+ 378
131
+ --> 379 raise MissingSchema(error)
132
+ 380
133
+ 381 if not host:
134
+
135
+ MissingSchema: Invalid URL '/search?q=EV+charge': No schema supplied. Perhaps you meant http:///search?q=EV+charge?