Aug-17-2017, 09:17 PM
So I have a script i'm trying to modify. It's suppose to fill out a form, however the search form has changed and I don't know how to modify the script so it updates the new fields
basically it goes to reserveramerica and searches camp sites given the parameters you enter (url = camp page) (length of stay - how many nights) (site code = camp site number/code) and date. However they've changed it now where CA sites are posted on reservecalifornia.com
It now asks for city, location/camp site name, type of camping, date and how many nights. When looking at the source, I dont know which form names I need to specify.
Any help would be deeply appreciated.
basically it goes to reserveramerica and searches camp sites given the parameters you enter (url = camp page) (length of stay - how many nights) (site code = camp site number/code) and date. However they've changed it now where CA sites are posted on reservecalifornia.com
It now asks for city, location/camp site name, type of camping, date and how many nights. When looking at the source, I dont know which form names I need to specify.
Any help would be deeply appreciated.
import os, sys, re, io, json, time import mechanize import pytz import smtplib import bs4 from datetime import datetime, timedelta from pytz import timezone from bs4 import BeautifulSoup from email.mime.text import MIMEText from datetime import date # Configuration url = "reserveamerica dot com/camping/nehalem-bay-state-park/r/campgroundDetails.do?contractCode=OR&parkId=402191" # url of your desired campground lengthOfStay = "1" # how many days you plan to stay siteCode = "" # the codes of your favorite camp sites here date = "10/01/2017" # the date you want to check # Create browser br = mechanize.Browser() # Browser options br.set_handle_equiv(True) br.set_handle_redirect(True) br.set_handle_referer(True) br.set_handle_robots(False) br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1); br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]; br.open(url); # Fill out form br.select_form(nr=0) br.form.set_all_readonly(False) # allow changing the .value of all controls br.form["campingDate"] = date br.form["lengthOfStay"] = lengthOfStay br.form["siteCode"] = siteCode response = br.submit()