Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lichenggang
/
update_cate
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
44fc82f9
authored
Apr 10, 2019
by
lichenggang
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
update
parent
e4b0ddd3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
28 deletions
plat/element14/cate_stock.py
updateopera.py
utils/mysqlopera.py
plat/element14/cate_stock.py
View file @
44fc82f9
...
@@ -4,7 +4,7 @@ url = 'https://hk.element14.com/browse-for-products'
...
@@ -4,7 +4,7 @@ url = 'https://hk.element14.com/browse-for-products'
# url='http://httpbin.org/ip'
# url='http://httpbin.org/ip'
a
=
Module_Base
()
a
=
Module_Base
()
headers
=
{
headers
=
{
"authority"
:
"
cn
.element14.com"
,
"authority"
:
"
hk
.element14.com"
,
"method"
:
"GET"
,
"method"
:
"GET"
,
"path"
:
"/browse-for-products"
,
"path"
:
"/browse-for-products"
,
"scheme"
:
"https"
,
"scheme"
:
"https"
,
...
@@ -12,7 +12,7 @@ headers = {
...
@@ -12,7 +12,7 @@ headers = {
"accept-encoding"
:
"gzip, deflate, br"
,
"accept-encoding"
:
"gzip, deflate, br"
,
"accept-language"
:
"zh-CN,zh;q=0.9"
,
"accept-language"
:
"zh-CN,zh;q=0.9"
,
"cache-control"
:
"max-age=0"
,
"cache-control"
:
"max-age=0"
,
"referer"
:
"https://
cn
.element14.com/"
,
"referer"
:
"https://
hk
.element14.com/"
,
"upgrade-insecure-requests"
:
"1"
,
"upgrade-insecure-requests"
:
"1"
,
"user-agent"
:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36"
,
"user-agent"
:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36"
,
}
}
...
@@ -40,5 +40,5 @@ for content_dom in content_sections:
...
@@ -40,5 +40,5 @@ for content_dom in content_sections:
level2
[
'level'
]
=
2
level2
[
'level'
]
=
2
level2
[
'islast'
]
=
1
level2
[
'islast'
]
=
1
level1
[
'level2_list'
]
.
append
(
level2
)
level1
[
'level2_list'
]
.
append
(
level2
)
#
print('二级分类',level2['cat_name'])
print
(
'二级分类'
,
level2
[
'cat_name'
])
levels
.
append
(
level1
)
levels
.
append
(
level1
)
updateopera.py
View file @
44fc82f9
...
@@ -20,10 +20,10 @@ class Updater():
...
@@ -20,10 +20,10 @@ class Updater():
def
update
(
self
,
cat_id
,
url
,
islast
,
level
,
parent_id
=
0
,
is_show
=
1
):
def
update
(
self
,
cat_id
,
url
,
islast
,
level
,
parent_id
=
0
,
is_show
=
1
):
with
self
.
operator
.
db
.
cursor
()
as
cursor
:
with
self
.
operator
.
db
.
cursor
()
as
cursor
:
sql
=
'UPDATE lie_category SET url=
%
s,islast=
%
s,level=
%
s,is_show=
%
s, parent_id=
%
s where cat_id=
%
s'
sql
=
'UPDATE lie_category SET url=
%
s,islast=
%
s,level=
%
s,is_show=
%
s, parent_id=
%
s where cat_id=
%
s'
data
=
(
url
,
islast
,
level
,
is_show
,
cat_id
,
paren
t_id
)
data
=
(
url
,
islast
,
level
,
is_show
,
parent_id
,
ca
t_id
)
cursor
.
execute
(
sql
,
data
)
cursor
.
execute
(
sql
,
data
)
def
insert
(
self
,
cat_name
,
url
,
islast
,
level
,
parent_id
=
0
,
is_show
=
1
,
sort_order
=
50
,
page_count
=
1
):
def
insert
(
self
,
cat_name
,
url
,
islast
,
level
,
parent_id
=
0
,
is_show
=
1
,
sort_order
=
50
,
page_count
=
1
):
with
self
.
operator
.
db
.
cursor
()
as
cursor
:
with
self
.
operator
.
db
.
cursor
()
as
cursor
:
sql
=
'INSERT into lie_category(cat_name,parent_id,sort_order,is_show,url,islast,level,page_count) values'
\
sql
=
'INSERT into lie_category(cat_name,parent_id,sort_order,is_show,url,islast,level,page_count) values'
\
...
@@ -53,4 +53,12 @@ class Updater():
...
@@ -53,4 +53,12 @@ class Updater():
else
:
else
:
pass
#TODO 增加三级分类
pass
#TODO 增加三级分类
self
.
operator
.
db
.
commit
()
self
.
operator
.
db
.
commit
()
\ No newline at end of file
# if __name__ == '__main__':
# uper = MySqlOperator('element14')
#
# with uper.db.cursor() as cursor:
# sql = 'UPDATE lie_category SET url=%s,islast=%s,level=%s,is_show=%s, parent_id=%s where cat_id=%s'
# cursor.execute(sql,('https://hk.element14.com/c/test-measurement/spectrometers',1,2,1,2379,'2391'))
# uper.db.commit()
\ No newline at end of file
utils/mysqlopera.py
View file @
44fc82f9
...
@@ -566,24 +566,3 @@ class MySqlOperator(object):
...
@@ -566,24 +566,3 @@ class MySqlOperator(object):
self
.
db
.
commit
()
self
.
db
.
commit
()
if
__name__
==
'__main__'
:
# pass
d
=
MySqlOperator
(
'chip1stop'
)
with
d
.
db
.
cursor
()
as
cursor
:
sql
=
"SELECT goods_id FROM lie_goods WHERE goods_name=
%
s and goods_name_style=
%
s"
cursor
.
execute
(
sql
,
(
'AD976AR'
,
'AD01-0000139'
))
result
=
cursor
.
fetchone
()
result
=
result
[
0
]
if
result
else
None
print
(
result
)
# print(d.get_ext_id_by_goods_id_attr_name(18000500790, 'Product Category'))
# data = (('SO180219037', '蔡**', '19**62A', 1519055525, '2018-02-19 23:52:05', 100, '已付3', '好好', '待取货3', 1519055525,
# 2519055525),
# ('SO180219035', '蔡**', '19**62A', 1519055525, '2018-02-19 23:52:05', 100, '衣付3', '好好', '待取货3', 1519055525,
# 2519055525))
# d.insert_lcsz_order_list(data)
# data1 = (
# ('SO180219034_3', 'SO180219037', '91383', '4.7nH ±0.3nH 编带', '高频电感', '0402', 500, 0.019, 0.0118, 1519055525),
# ('SO180219034_4', 'SO180219037', '91383', '4.7nH ±0.3nH 编带', '高频电感', '0402', 500, 0.019, 0.0118, 1519055525),
# )
# d.insert_lcsz_order_details(data1)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment