Android Question http problems about cookies

cup319

Member

i want to get the json by post the url,
but it seems like something error happened.
maybe it's about the cookies.

THANKS

t2:
#Region  Project Attributes
    #ApplicationLabel: XXXXXX
    #VersionCode: 1
    #VersionName: 1.0
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
End Sub

Sub Globals
    Private Button1 As Button
    Private EditText1 As EditText
    Private WebView1 As WebView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub Button1_Click
    Dim j As HttpJob
    j.Initialize("",Me)
    'j.PostMultipart("https://movie.douban.com/j/search_subjects?Type=tv&tag=%E7%83%AD%E9%97%A8&sort=recommend&page_limit=50&page_start=0",Null,Null)
    j.PostMultipart("https://movie.douban.com",Null,Null)
    
    'j.PostMultipart("http://www.163.com",Null,Null)
'    'j.GetString("http://www.baidu.com")
    j.GetRequest.SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36")
    j.GetRequest.SetHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")
    j.GetRequest.SetHeader("Cookie","""bid=eQsouengau0""; ll=""118177""; __yadk_uid=l8Pl0hJOKqof5krHjsB0ELtt1NrWPDbD; __utma=30149280.211996512.1617348476.1617348476.1617348476.1; __utmz=30149280.1617348476.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=223695111.1756605094.1617348476.1617348476.1617348476.1; __utmz=223695111.1617348476.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); ap_v=0,6.0; _pk_ref.100001.4cf6=%5B%22%22%2C%22%22%2C1618382517%2C%22https%3A%2F%2Fwww.douban.com%2F%22%5D; _pk_ses.100001.4cf6=*; _pk_id.100001.4cf6=242be1cfb8b77136.1617348466.2.1618382526.1617348486.""")
'   
    'WebView1.LoadUrl("https://www.baidu.com/img/PCfb_5bf082d29588c07f842ccde3f97243ea.png")
    'WebView1.LoadUrl("https://movie.douban.com/j/search_subjects?type=tv&tag=%E7%83%AD%E9%97%A8&sort=recommend&page_limit=50&page_start=0")
    
    
    wait for (j) JobDone(job As HttpJob)
    If job.Success Then
        Dim response As String = job.GetString
        Log(response)
        EditText1.Text=response
    Else
        Log(job.ErrorMessage)
        EditText1.Text=job.ErrorMessage
    End If

    
End Sub

微信截图_20210415134308.png
 

Attachments

  • http.zip
    186 KB · Views: 232

cup319

Member
the cookies:
GET /j/search_subjects?Type=tv&tag=%E7%83%AD%E9%97%A8&sort=recommend&page_limit=50&page_start=0 HTTP/1.1
Host: movie.douban.com
Connection: keep-alive
Cache-Control: max-age=0
DNT: 1
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Sec-Fetch-Site: none
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Cookie: bid=eQsouengau0; ll="118177"; __yadk_uid=l8Pl0hJOKqof5krHjsB0ELtt1NrWPDbD; __utma=30149280.211996512.1617348476.1617348476.1617348476.1; __utmz=30149280.1617348476.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=223695111.1756605094.1617348476.1617348476.1617348476.1; __utmz=223695111.1617348476.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _pk_ref.100001.4cf6=%5B%22%22%2C%22%22%2C1618382517%2C%22https%3A%2F%2Fwww.douban.com%2F%22%5D; _pk_id.100001.4cf6=242be1cfb8b77136.1617348466.2.1618382526.1617348486.
 
Upvote 0

cup319

Member
it's ok...:
Sub Button1_Click
    Dim j As HttpJob
    j.Initialize("", Me)
    j.Download("https://movie.douban.com/j/search_subjects?type=tv&tag=%E7%83%AD%E9%97%A8&sort=recommend&page_limit=20&page_start=0")
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Log(j.GetString)
    End If
    j.Release
End Sub
 
Upvote 0
Top