문제

<div class="group group-form group-form-requiredinformation">
    <h2 class="sr">Required Information</h2>

    <ol class="list-input">
      <li class="field required text" id="field-email">
        <label for="email">E-mail</label>
        <input class="" id="email" type="email" name="email" value="" placeholder="example: username@domain.com" required aria-required="true" aria-described-by="email-tip" />
        <span class="tip tip-input" id="email-tip">This is the e-mail address you used to register with edX</span>
      </li>
      <li class="field required password" id="field-password">
        <label for="password">Password</label>
        <input id="password" type="password" name="password" value="" required aria-required="true" />
        <span class="tip tip-input">

I am trying to write some code that will parse a webpage and check for updated content periodically, my problem is that I need to be logged in but I am unsure how to pass in my login details, the above is some of the source of the login page, how is it possible to achieve this?

I have tried something like the code below but to no avail.

browser = mechanize.Browser()
browser.open("https:xxxx")
browser.select_form(nr = 0)
browser.form['username'] = "email"
browser.form['password'] = "xxxxx"
browser.submit()
도움이 되었습니까?

해결책

At least, the field is called email, not username:

browser.form['email'] = "email"
browser.form['password'] = "xxxxx"
browser.submit()

다른 팁

store the last updated date time in a variable and have a javascript timer function to invoke a function to check the last updated date time and if the content was updated more than the predefined time, make a call to backend and update the info on the page.

FYI.. there is no browser object. there is document object which has properties and methods to manipulate the page

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