Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lichenggang
/
seo_checker
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
57f8de99
authored
Sep 25, 2019
by
lichenggang
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
update mouser
根据url获取数据的函数里面改为不设置cookie
parent
52850dec
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
5 deletions
test_log.py
test_log.py
View file @
57f8de99
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from
utils.log_manager
import
LogManager
from
concurrent.futures
import
ThreadPoolExecutor
,
as_completed
import
re
from
lxml
import
etree
import
requests
test_log
=
LogManager
(
'test'
)
.
get_logger_and_add_handlers
(
log_path
=
'./logs'
,
log_filename
=
'test.log'
)
test_log
.
debug
(
'这一句不会重复打印四次和写入日志四次'
)
exector
=
ThreadPoolExecutor
(
max_workers
=
5
)
# headers={
# "authority":"www.mouser.hk",
# "method":"GET",
# "path":"/ProductDetail/Microchip-Technology/MCP1630RD-LIC2?qs=%2Fha2pyFadugOTv0PoQ7miVOX9mwJ5UAQzQQqwV9rhh5KjEhYK%252blX8g==",
# "scheme":"https",
# "accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
# "accept-encoding":"gzip, deflate, br",
# "accept-language":"zh-CN,zh;q=0.9",
# "cache-control":"no-cache",
# "pragma":"no-cache",
# "referer":"https://www.mouser.hk/",
# "sec-fetch-mode":"navigate",
# "sec-fetch-site":"same-origin",
# "sec-fetch-user":"?1",
# "upgrade-insecure-requests":"1",
# "user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.75 Safari/537.36",
# }
web_headers
=
{
'host'
:
"www.mouser.hk"
,
# 'connection': 'close',
'accept'
:
"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"
,
'accept-encoding'
:
"gzip, deflate, br"
,
'accept-language'
:
"zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7,mt;q=0.6"
,
'cache-control'
:
"max-age=0,no-cache"
,
'referer'
:
"https://www.mouser.hk/"
,
'upgrade-insecure-requests'
:
"1"
,
'user-agent'
:
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/71.0.3578.98 Safari/537.36"
,
}
url
=
"https://www.mouser.hk/ProductDetail/Microchip-Technology/MCP1630RD-LIC2?qs=
%2
Fha2pyFadugOTv0PoQ7miVOX9mwJ5UAQzQQqwV9rhh5KjEhYK
%252
blX8g=="
resp
=
requests
.
get
(
url
,
headers
=
web_headers
)
print
(
resp
.
text
)
\ No newline at end of file
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