Skip to content

Commit c9320c1

Browse files
committed
'init'
0 parents  commit c9320c1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1517
-0
lines changed

.idea/PythonStudy.iml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 526 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.vscode/launch.json

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Python",
6+
"type": "python",
7+
"request": "launch",
8+
"stopOnEntry": false,
9+
"pythonPath": "${config.python.pythonPath}",
10+
"program": "${file}",
11+
"cwd": "${workspaceRoot}",
12+
"env": null,
13+
"envFile": "${workspaceRoot}/.env",
14+
"debugOptions": [
15+
"WaitOnAbnormalExit",
16+
"WaitOnNormalExit",
17+
"RedirectOutput"
18+
]
19+
},
20+
{
21+
"name": "PySpark",
22+
"type": "python",
23+
"request": "launch",
24+
"stopOnEntry": true,
25+
"osx": {
26+
"pythonPath": "${env.SPARK_HOME}/bin/spark-submit"
27+
},
28+
"windows": {
29+
"pythonPath": "${env.SPARK_HOME}/bin/spark-submit.cmd"
30+
},
31+
"linux": {
32+
"pythonPath": "${env.SPARK_HOME}/bin/spark-submit"
33+
},
34+
"program": "${file}",
35+
"cwd": "${workspaceRoot}",
36+
"env": null,
37+
"envFile": "${workspaceRoot}/.env",
38+
"debugOptions": [
39+
"WaitOnAbnormalExit",
40+
"WaitOnNormalExit",
41+
"RedirectOutput"
42+
]
43+
},
44+
{
45+
"name": "Python Module",
46+
"type": "python",
47+
"request": "launch",
48+
"stopOnEntry": true,
49+
"pythonPath": "${config.python.pythonPath}",
50+
"module": "module.name",
51+
"cwd": "${workspaceRoot}",
52+
"env": null,
53+
"envFile": "${workspaceRoot}/.env",
54+
"debugOptions": [
55+
"WaitOnAbnormalExit",
56+
"WaitOnNormalExit",
57+
"RedirectOutput"
58+
]
59+
},
60+
{
61+
"name": "Integrated Terminal/Console",
62+
"type": "python",
63+
"request": "launch",
64+
"stopOnEntry": true,
65+
"pythonPath": "${config.python.pythonPath}",
66+
"program": "${file}",
67+
"cwd": null,
68+
"console": "integratedTerminal",
69+
"env": null,
70+
"envFile": "${workspaceRoot}/.env",
71+
"debugOptions": [
72+
"WaitOnAbnormalExit",
73+
"WaitOnNormalExit"
74+
]
75+
},
76+
{
77+
"name": "External Terminal/Console",
78+
"type": "python",
79+
"request": "launch",
80+
"stopOnEntry": true,
81+
"pythonPath": "${config.python.pythonPath}",
82+
"program": "${file}",
83+
"cwd": null,
84+
"console": "externalTerminal",
85+
"env": null,
86+
"envFile": "${workspaceRoot}/.env",
87+
"debugOptions": [
88+
"WaitOnAbnormalExit",
89+
"WaitOnNormalExit"
90+
]
91+
},
92+
{
93+
"name": "Django",
94+
"type": "python",
95+
"request": "launch",
96+
"stopOnEntry": true,
97+
"pythonPath": "${config.python.pythonPath}",
98+
"program": "${workspaceRoot}/manage.py",
99+
"cwd": "${workspaceRoot}",
100+
"args": [
101+
"runserver",
102+
"--noreload"
103+
],
104+
"env": null,
105+
"envFile": "${workspaceRoot}/.env",
106+
"debugOptions": [
107+
"WaitOnAbnormalExit",
108+
"WaitOnNormalExit",
109+
"RedirectOutput",
110+
"DjangoDebugging"
111+
]
112+
},
113+
{
114+
"name": "Flask",
115+
"type": "python",
116+
"request": "launch",
117+
"stopOnEntry": false,
118+
"pythonPath": "${config.python.pythonPath}",
119+
"program": "fully qualified path fo 'flask' executable. Generally located along with python interpreter",
120+
"cwd": "${workspaceRoot}",
121+
"env": {
122+
"FLASK_APP": "${workspaceRoot}/quickstart/app.py"
123+
},
124+
"args": [
125+
"run",
126+
"--no-debugger",
127+
"--no-reload"
128+
],
129+
"envFile": "${workspaceRoot}/.env",
130+
"debugOptions": [
131+
"WaitOnAbnormalExit",
132+
"WaitOnNormalExit",
133+
"RedirectOutput"
134+
]
135+
},
136+
{
137+
"name": "Flask (old)",
138+
"type": "python",
139+
"request": "launch",
140+
"stopOnEntry": false,
141+
"pythonPath": "${config.python.pythonPath}",
142+
"program": "${workspaceRoot}/run.py",
143+
"cwd": "${workspaceRoot}",
144+
"args": [],
145+
"env": null,
146+
"envFile": "${workspaceRoot}/.env",
147+
"debugOptions": [
148+
"WaitOnAbnormalExit",
149+
"WaitOnNormalExit",
150+
"RedirectOutput"
151+
]
152+
},
153+
{
154+
"name": "Pyramid",
155+
"type": "python",
156+
"request": "launch",
157+
"stopOnEntry": true,
158+
"pythonPath": "${config.python.pythonPath}",
159+
"cwd": "${workspaceRoot}",
160+
"env": null,
161+
"envFile": "${workspaceRoot}/.env",
162+
"args": [
163+
"${workspaceRoot}/development.ini"
164+
],
165+
"debugOptions": [
166+
"WaitOnAbnormalExit",
167+
"WaitOnNormalExit",
168+
"RedirectOutput",
169+
"Pyramid"
170+
]
171+
},
172+
{
173+
"name": "Watson",
174+
"type": "python",
175+
"request": "launch",
176+
"stopOnEntry": true,
177+
"pythonPath": "${config.python.pythonPath}",
178+
"program": "${workspaceRoot}/console.py",
179+
"cwd": "${workspaceRoot}",
180+
"args": [
181+
"dev",
182+
"runserver",
183+
"--noreload=True"
184+
],
185+
"env": null,
186+
"envFile": "${workspaceRoot}/.env",
187+
"debugOptions": [
188+
"WaitOnAbnormalExit",
189+
"WaitOnNormalExit",
190+
"RedirectOutput"
191+
]
192+
},
193+
{
194+
"name": "Attach (Remote Debug)",
195+
"type": "python",
196+
"request": "attach",
197+
"localRoot": "${workspaceRoot}",
198+
"remoteRoot": "${workspaceRoot}",
199+
"port": 3000,
200+
"secret": "my_secret",
201+
"host": "localhost"
202+
}
203+
]
204+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#PythonStudy

baike.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# -*- coding: utf-8 -*-
2+
# @Author: liuhao
3+
# @Date: 2017-02-25 10:52:01
4+
# @Last Modified by: liuhao
5+
# @Last Modified time: 2017-02-25 12:43:42
6+
7+
import urllib
8+
from bs4 import BeautifulSoup
9+
10+
base_url = "http://baike.baidu.com/item/"
11+
html = "";
12+
13+
def getHTML(url):
14+
response = urllib.urlopen(url)
15+
global html
16+
html = response.read()
17+
print html
18+
19+
def parse():
20+
soup = BeautifulSoup(html,"html.parser")
21+
main = soup.select("div[class=main-content]")
22+
if len(main)==1:
23+
m = main[0]
24+
summary = m.select("div[class=lemma-summary]")
25+
print type(summary)
26+
# if len(summary)==1:
27+
# s = summary[0]
28+
# print s
29+
else:
30+
print len(main)
31+
print "aaa"
32+
33+
keyword = raw_input("please input keyword that you want to check.")
34+
35+
getHTML(base_url+keyword)
36+
parse()
37+

deyi.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
# @Author: liuhao
3+
# @Date: 2017-02-23 21:51:46
4+
# @Last Modified by: liuhao
5+
# @Last Modified time: 2017-02-23 23:10:53
6+
from bs4 import BeautifulSoup
7+
import urllib
8+
9+
deyihHome = ""
10+
def getDeyi():
11+
response = urllib.urlopen("http://www.deyi.com")
12+
global deyiHome
13+
deyiHome = response.read()
14+
15+
def parseTopNews():
16+
soup = BeautifulSoup(deyiHome,"html.parser")
17+
center = soup.select("div[id=icf_center_front]")
18+
topNewsList = center[0].select("div[class=article_brief]")
19+
print len(topNewsList)
20+
21+
for item in topNewsList:
22+
topNews = item
23+
a = topNews.select("a")
24+
print a[0].string
25+
26+
getDeyi()
27+
parseTopNews()

0 commit comments

Comments
 (0)