로그인해야 하는 URL과 JSL 로그인을 통해 쿠키를 얻고 데이터를 다운로드하는 방법.여러분, 안녕하세요!
이 사이트는 전체 데이터를 다운로드하기 위해 쿠키가 필요합니다. JSL 로그인을 통해 쿠키를 얻고 데이터를 다운로드하려면 어떻게 합니까?
감사해요!
VBA
Sub Post()
Dim User_agent, Response_Text, username, password, cookie, json
username = [d1]: password = [f1]
User_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36"
Post_data = "return_url=https%3A%2F%2Fwww.jisilu.cn%2Fdata%2Fcbnew%2F&user_name=" & jslencode(username) & "&password=" & jslencode(password) & "&aes=1&auto_login=0"
With CreateObject("WinHttp.WinHttpRequest.5.1")
.Open "get", "https://www.jisilu.cn/login/", False
.setrequestheader "User-Agent", User_agent
.send
.Open "post", "https://www.jisilu.cn/webapi/account/login_process/", False
.setrequestheader "User-Agent", User_agent
.setrequestheader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"
.send (Post_data)
cookie = Split(.getallresponseheaders, "Set-Cookie: ")(2)
.Open "get", "https://www.jisilu.cn/data/cbnew/detail_hist/" & ([b1] & ""), False
.setrequestheader "User-Agent", User_agent
.setrequestheader "cookie", cookie
.send "fprice=&tprice=&curr_iss_amt=&volume=&svolume=&premium_rt=&ytm_rt=&rating_cd=&is_search=N&market_cd%5B%5D=shmb&market_cd%5B%5D=shkc&market_cd%5B%5D=szmb&market_cd%5B%5D=szcy&btype=&listed=Y&qflag=N&sw_cd=&bond_ids=&rp=50&page=1"
Response_Text = .responsetext
Set json = JsonConverter.ParseJson(Response_Text)
End With
End Sub스크립팅창Re: 로그인해야 하는 url과 JSL 로그인을 통해 쿠키를 얻고 데이터를 다운로드하는 방법.저는 VB 사용자는 아니지만 3개의 newHttpRequests를 사용하여 JMP에서 작동해야 하는 것처럼 보입니다.
VB 코드의 세 섹션은 ".send"로 끝납니다.
첫 번째 섹션은 로그인 페이지로 이동합니다. 그것이 왜 필요한지 확실하지 않습니다... 쿠키를 제공하지는 않지만 먼저 쿠키를 방문해야 할 수도 있습니다.
두 번째 섹션은 로그인했음을 의미하는 쿠키를 제공하는 URL로 post_data를 보냅니다.
JMP의 httprequest는 해당 데이터를 유지할 수 있습니다. 또는 httprequest에 이를 파일에 쓴 다음 파일에서 가져오도록 지시해야 할 수도 있습니다.
(2)는 일종의 VB 구조에서 쿠키 값을 가져옵니다.
세 번째 섹션은 URL을 사용하여 일부 데이터를 가져오고 쿠키를 자격 증명으로 제공합니다. JMP가 당신을 위해 그렇게 할 수 있습니다.
// get a cookie
try(deletefile("$temp/cookie.txt"));
s = New HTTP Request(
URL( "http://httpbin.org/cookies/set/aaa/bbb" ),
Method( "GET" ),
Headers( {"Accept: application/json", "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/99.0"} ),
cookiefile("$temp/cookie.txt")
);
data = s << Send;
show(loadtextfile("$temp/cookie.txt"));
// send a cookie
s = New HTTP Request(
URL( "http://httpbin.org/cookies" ),
Method( "GET" ),
Headers( {
"Accept: application/json",
"Cookie: PHPSESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1",
"User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/99.0"
} )
);
data = s << Send;
Show( data ); // note the aaa cookie was persisted
Re: 로그인해야 하는 url과 JSL 로그인을 통해 쿠키를 얻고 데이터를 다운로드하는 방법.
여러 번 시도했지만 직접 로그인하여 전체 데이터를 다운로드할 수 있는 방법이 없습니다.
인터넷에서 Python 코드를 찾았지만 여전히 작동하지 않습니다.

Re: 로그인해야 하는 url과 JSL 로그인을 통해 쿠키를 얻고 데이터를 다운로드하는 방법.class AllcontentSpider(scrapy.Spider):
name = 'allcontent'
headers = {
'Host': 'www.jisilu.cn', 'Connection': 'keep-alive', 'Pragma': 'no-cache',
'Cache-Control': 'no-cache', 'Accept': 'application/json,text/javascript,*/*;q=0.01',
'Origin': 'https://www.jisilu.cn', 'X-Requested-With': 'XMLHttpRequest',
'User-Agent': 'Mozilla/5.0(WindowsNT6.1;WOW64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/67.0.3396.99Safari/537.36',
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
'Referer': 'https://www.jisilu.cn/login/',
'Accept-Encoding': 'gzip,deflate,br',
'Accept-Language': 'zh,en;q=0.9,en-US;q=0.8'
}
def start_requests(self):
login_url = 'https://www.jisilu.cn/login/'
headers = {
'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,en;q=0.9,en-US;q=0.8',
'Cache-Control': 'no-cache', 'Connection': 'keep-alive',
'Host': 'www.jisilu.cn', 'Pragma': 'no-cache', 'Referer': 'https://www.jisilu.cn/',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0(WindowsNT6.1;WOW64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/67.0.3396.99Safari/537.36'}
yield Request(url=login_url, headers=headers, callback=self.login,dont_filter=True)
def login(self, response):
url = 'https://www.jisilu.cn/account/ajax/login_process/'
data = {
'return_url': 'https://www.jisilu.cn/',
'user_name': config.username,
'password': config.password,
'net_auto_login': '1',
'_post_type': 'ajax',
}
yield FormRequest(
url=url,
headers=self.headers,
formdata=data,
callback=self.parse,
dont_filter=True
)
def parse(self, response):
for i in range(1,3726):
focus_url = 'https://www.jisilu.cn/home/explore/sort_type-new__day-0__page-{}'.format(i)
yield Request(url=focus_url, headers=self.headers, callback=self.parse_page,dont_filter=True)
def parse_page(self, response):
nodes = response.xpath('//div[@class="aw-question-list"]/div')
for node in nodes:
each_url=node.xpath('.//h4/a/@href').extract_first()
yield Request(url=each_url,headers=self.headers,callback=self.parse_item,dont_filter=True)
def parse_item(self,response):
item = JslItem()
title = response.xpath('//div[@class="aw-mod-head"]/h1/text()').extract_first()
s = response.xpath('//div[@class="aw-question-detail-txt markitup-box"]').xpath('string(.)').extract_first()
ret = re.findall('(.*?)\.donate_user_avatar', s, re.S)Re: 로그인해야 하는 url과 JSL 로그인을 통해 쿠키를 얻고 데이터를 다운로드하는 방법.작동하지 않습니다:
<BR />s = New HTTP Request( URL( "https://www.jisilu.cn/login" ), Method( "get" ) );
data = s << Send;
username = "lala";
password = "jmp";
jj = "return_url=http://www.jisilu.cn/&user_name=" || username || "&password=" || password || "&net_auto_login=1&_post_type=ajax";
h = [=> ];
h["Content-Type"] = "application/json";
h["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36";
h["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
s = New HTTP Request( URL( "https://www.jisilu.cn/webapi/account/login_process/" ), Method( "POST" ), JSON( jj ), Headers( h ) );
data1 = s << Send;
Re: 로그인해야 하는 url과 JSL 로그인을 통해 쿠키를 얻고 데이터를 다운로드하는 방법.이것은 이 포럼의 범위를 벗어납니다. 아마도 사이트는 원하는 작업에 대한 API를 제공합니다.
사이트에서 자바스크립트를 사용하여 올바르게 로그인했는지 확인하는 데 도움이 된다고 생각합니다.JMP는 자바스크립트를 실행하지 않습니다.
보안 문자는 문제의 일부일 수 있으며 사람의 상호 작용이 필요할 수 있습니다.
사용자 이름이나 암호에 특수 문자가 포함되어 있으면 일종의 인코딩이 필요합니다.
413 오류 코드는 다른 문제가 있음을 의미할 수 있습니다.