get 메소드를 사용하는 getForm - 리디렉션을 우회하는 방법은 무엇입니까?

StackOverflow https://stackoverflow.com//questions/23036089

문제

나는 이것 때문에 어려움을 겪고 있다 getForm 내 쿼리를 리디렉션하는 문제입니다.나는 실험을 시도했다. cookiefile 그리고 followlocation Stackoverflow의 다른 주제와 마찬가지로 결과가 없습니다.

내 코드:

  getForm("http://korpus.pl/poliqarp/poliqarp.php",
          query = "pies", corpus = "2", showMatch = "1",showContext = "3",
          leftContext = "5", rightContext = "5", wideContext = "50", hitsPerPage = "10",              
          .opts = curlOptions(
            verbose = TRUE,
            followlocation=TRUE
            )
      )

리디렉션 페이지의 내용을 받고 있는 것이 맞습니까?그렇다면 어떻게 우회할 수 있나요?

도움이 되었습니까?

해결책

curl = getCurlHandle(cookiefile = "", verbose = TRUE, followlocation=TRUE)

getForm("http://korpus.pl/poliqarp/poliqarp.php",
        query = "pies", corpus = "2", showMatch = "1",showContext = "3",
        leftContext = "5", rightContext = "5", wideContext = "50", hitsPerPage = "10",              
        .opts = curlOptions(
          verbose = TRUE,
          followlocation=TRUE
        )
        , curl = curl)


test1 <- getURL("http://korpus.pl/poliqarp/poliqarp.php", curl = curl)
test2 <- getURL("http://korpus.pl/poliqarp/poliqarp.php", curl = curl)

약간의 설득을 통해 test2에 결과가 포함되기를 바랍니다.

컬은 호출 전반에 걸쳐 지속되는 핸들입니다.환경 cookiefile RCurl에게 쿠키를 저장하라고 지시합니다.다음을 사용하여 컬 핸들의 정보에 액세스할 수 있습니다. getCurlInfo(curl).예를 들어

> cat(getCurlInfo(curl)$cookielist)
korpus.pl   FALSE   /   FALSE   0   PHPSESSID   ark8hbi13e2c4qrp51aq51nj62

getForm 호출은 중요한 쿠키를 설정합니다. PHPSESSID.첫 번째 getURL 결과는 다음과 같습니다.

> library(XML)
> htmlParse(test1)['//h3'][[1]]
<h3>This page will <a href="poliqarp.php">refresh</a> automatically in a second</h3> 

아마도 자바스크립트를 사용하여 자동으로 새로 고쳐질 것이라고 알려주므로 다른 호출을 실행하여 이 새로 고침을 수동으로 수행해야 합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top