Hmmm...
Code: Select all
EnableExplicit
IncludeFile "libcurl.pbi"
Procedure.s HttpTest(URL$, PostData$ = "", Cookie$ = "", User_agent$ = "", Referer$ = "", Proxy$ = "",json.i = #False, Timeout.i = 3000)
Protected curl.i, Result$, newCookie$, tmp$, i.i, res.i, Header$
curl = curl_easy_init()
If curl
curl_easy_setopt_str(curl, #CURLOPT_URL, URL$)
If Cookie$ <> ""
curl_easy_setopt_str(curl, #CURLOPT_COOKIE, Cookie$)
EndIf
If User_agent$ <> ""
curl_easy_setopt_str(curl, #CURLOPT_USERAGENT, User_agent$)
EndIf
If PostData$ <> ""
curl_easy_setopt(curl, #CURLOPT_POST, 1)
curl_easy_setopt_str(curl, #CURLOPT_COPYPOSTFIELDS, PostData$)
EndIf
curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYPEER, 0)
curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYHOST, 0)
curl_easy_setopt(curl, #CURLOPT_HEADER, 1)
curl_easy_setopt(curl, #CURLOPT_WRITEFUNCTION, @LibCurl_WriteFunction())
curl_easy_setopt(curl, #CURLOPT_FOLLOWLOCATION, 1)
If Proxy$ <> ""
curl_easy_setopt_str(curl, #CURLOPT_PROXY, Proxy$)
EndIf
curl_easy_setopt(curl, #CURLOPT_TIMEOUT_MS, Timeout)
If Referer$ <> ""
curl_easy_setopt_str(curl, #CURLOPT_REFERER, Referer$)
EndIf
res = curl_easy_perform(curl)
If res = #CURLE_OK
Result$ = LibCurl_GetData()
Debug Result$
i = FindString(Result$, #CRLF$ + #CRLF$)
If i
Header$ = Left(Result$, i)
i = 1
Repeat
tmp$ = StringField(Header$, i, #CRLF$)
If tmp$ <> ""
Debug "Headerfield: " + tmp$
If Left(tmp$, 11) = "Set-Cookie:"
newCookie$ + Mid(tmp$, 13) + #CRLF$
Debug newCookie$
EndIf
i + 1
EndIf
Until tmp$ = ""
EndIf
Else
Debug curl_easy_strerror(res)
EndIf
curl_easy_cleanup(curl)
EndIf
ProcedureReturn newCookie$ + " ###ENDCookie### "+ #CRLF$ + Result$
EndProcedure
Procedure.s FindCoockiElement(element.s,cookie.s)
Protected.s name_element, value_element, tmp_element, name_tmp_element, tmp_cookie
Protected.i count_elements,i
name_element = StringField(element, 1, "=")
value_element = StringField(element, 2, "=")
If FindString(cookie,name_element)
count_elements = CountString(cookie,";")
For i=1 To count_elements + 1
tmp_element = Trim(StringField(cookie, i, ";"))
name_tmp_element = StringField(tmp_element,1,"=")
If name_tmp_element = name_element
tmp_element = element
EndIf
tmp_cookie = tmp_cookie + tmp_element +"; "
Next
Else
tmp_cookie = cookie +"; "+ element
EndIf
ProcedureReturn RTrim(RTrim(tmp_cookie),";")
EndProcedure
Procedure.s GetCookies(html.s, old_cookies.s)
Protected.s StringCookies, tmp_cookie, temp_text, tmp2_cookie
Protected.i count_space, j, count_element
tmp_cookie = StringField(html, 1, " ###ENDCookie### ")
tmp_cookie = ReplaceString(tmp_cookie, #CR$,"; ")
tmp_cookie = ReplaceString(tmp_cookie, #LF$,"; ")
tmp_cookie = ReplaceString(tmp_cookie, #CRLF$,"; ")
tmp_cookie = RemoveString(tmp_cookie,"HttpOnly")
tmp_cookie = RemoveString(tmp_cookie,"Domain=.ebay.com")
tmp_cookie = RemoveString(tmp_cookie,"Path=/")
count_space = CountString(tmp_cookie, ";")
For j = 1 To count_space + 1
temp_text = Trim(StringField(tmp_cookie, j, ";"))
If Not temp_text =""
If FindString(temp_text,"Expires",1, #PB_String_NoCase) = 0
count_element = CountString(tmp_cookie, temp_text)
If count_element > 1
tmp2_cookie = tmp2_cookie + RemoveString(tmp_cookie, temp_text+"; ", #PB_String_CaseSensitive, 1, count_element - 1)
Else
tmp2_cookie = tmp2_cookie + temp_text + "; "
EndIf
EndIf
EndIf
Next
StringCookies = RTrim(RTrim(ReplaceString(tmp2_cookie, "; ; ", "; ")),";")
If Not old_cookies = ""
count_element = CountString(StringCookies+old_cookies, ";")
For j = 1 To count_element
temp_text = Trim(StringField(StringCookies, j, ";"))
If Not temp_text =""
old_cookies = FindCoockiElement(temp_text, old_cookies)
EndIf
Next
StringCookies = old_cookies
EndIf
ProcedureReturn StringCookies
EndProcedure
Define htmll$
htmll$ = HttpTest("https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&en=https%3A%2F%2Fwww.ebay.com%2F", "", "", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)")
Debug GetCookies( htmll$,"")
But in the answer is no cookie ...