I'm trying to fill the form that is at www.wetseal.com/Stores that allows selecting the state to show stores from.
<form action="http://www.wetseal.com/Stores?dwcont=C73689620" method="post" id="dwfrm_storelocator_state">
<fieldset>
<div class="form-row required ">
<label for="dwfrm_storelocator_address_states_stateUSCA">
<span>State</span>
<span class="required-indicator">*</span>
</label>
<select id="dwfrm_storelocator_address_states_stateUSCA" class="input-select required" name="dwfrm_storelocator_address_states_stateUSCA">
<option value="">Select...</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="PR">Puerto Rico</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
</select>
</div>
<button type="submit" name="dwfrm_storelocator_findbystate" value="Search">
Search
</button>
</fieldset>
</form>
Looking with Chrome I can see the request being made and the form params:
That said, I have a very simple spider that, looking at the docs, sends a FormRequest to that URL to fill the form (In this case I'm testing for Arizona shops - AZ):
class WetSealStoreSpider(Spider):
name = "wetseal_store_spider"
allowed_domains = ["wetseal.com"]
start_urls = [
"http://www.wetseal.com/Stores"
]
def parse(self, response):
yield FormRequest.from_response(response,
formname='dwfrm_storelocator_state',
formdata={'dwfrm_storelocator_address_states_stateUSCA': 'AZ',
'dwfrm_storelocator_findbystate': 'Search'},
callback=self.parse1)
def parse1(self, response):
print response.status
print response.body
When it gets to make the FormRequest, looking at the response, everything seems OK:
But in the callback method, I see this in the response:
It looked like a GET request was made at the end, and the url is all wrong:
'http://www.wetseal.com/Search?q=&dwfrm_storelocator_findbystate=Search&dwfrm_storelocator_address_states_stateUSCA=AZ'
Any idea what I'm doing wrong?
Thanks!
You're using formname but the form doesn't have a name.
Try using formxpath='id("dwfrm_storelocator_state")' instead.
try this
states = response.xpath(
".//select[#id='dwfrm_storelocator_address_states_stateUSCA']//option[#value!='']/#value").extract()
url = self.get_text_from_node(response.xpath("//form[#id='dwfrm_storelocator_state']/#action"))
for state in states:
form_data = {'dwfrm_storelocator_address_states_stateUSCA': state,
"dwfrm_storelocator_findbystate": "Search"}
yield FormRequest(url,
formdata=form_data,
callback=self.your_Callback)
Related
Here is my Multiselect
<div class="form-group">
<label>Multiple select using select 2</label>
<select class="js-example-basic-multiple w-100" id='mls' name="resources" multiple="multiple">
<option value="AL">Alabama</option>
<option value="WY">Wyoming</option>
<option value="AM">America</option>
<option value="CA">Canada</option>
<option value="RU">Russia</option>
</select>
</div>
Whenever I try to post despite selecting multiple values I still get only one .
Here is stacktrace.
Variable Value
csrfmiddlewaretoken
'aI5tuSxOtxzGOpMDKR4RcH685yWUFpqkgTeBrYVbQ8kN9ODxnPOytllMTAb11Bib'
acc_id
'1'
resources
'AM'
I tried with getlist as well still getting single value we all can see single values are passing in request itself.
Not sure what might I am doing wrong here .
It seems you are send single value from front.
i tested it:
<form method="GET">
<div class="form-group">
<label>Multiple select using select 2</label>
<select class="js-example-basic-multiple w-100" id='mls' name="resources" multiple="multiple">
<option value="AL">Alabama</option>
<option value="WY">Wyoming</option>
<option value="AM">America</option>
<option value="CA">Canada</option>
<option value="RU">Russia</option>
</select>
</div>
<button type="submit">Show me markers</button>
</form>
i see in request:
"GET /test/testmarkers/?resources=WY&resources=AM HTTP/1.1" 200 1867
And i am sure, you are use not Form.send(). How are you send it?
I have to select a checkbox from within a drop down. The problem is the value is not visible. I need to scroll down to reach the value.
html
<select class="select_box" tabindex="25" id="cbo_CC_CType"
name="cbo_CC_CType" multiple="multiple" multi-select="true"
autofillkey="CMDTYPE" title="COMMAND TYPE">
<option value="Authorization">Authorization</option>
<option value="Cancel">Cancel</option>
<option value="Change">Change</option>
<option value="Clear">Clear</option>
<option value="Final">Final</option>
<option value="Final1">Final</option>
<option value="Fina2">Final</option>
<option value="Fina3">Final</option>
.
.
.
.
.
.
<option value="MyCar">MyCar</option>
</select>
I tried:
chromedriver.find_element_by_xpath("//select[#id='cbo_CC_CType']/option[#value='MyCar']").click()
Can someone please help
I need to have Amazon affiliate API for autocompletion work with SearchIndex (Marketplace category)
For example,
I have a site that searches for Kindle Books, and would like to have Amazon's autocompletion only return Kindle Book results.
The following URL will return all products with the keyword 'photography'
http://completion.amazon.com/search/complete?search-alias=aps&client=amazon-search-ui&mkt=1&q=photography
How can I have the above URL return only Kindle Books with keyword 'photography'?
I have found the solution.
The search-alias query needs to be changed to digital-text, like so:
http://completion.amazon.com/search/complete?search-alias=digital-text&client=amazon-search-ui&mkt=1&q=photography
You can do this for any marketplace category by changing search-alias to the appropriate query variable.
Here's a complete list of search-alias variables:
<select>
<option selected="selected" value="search-alias=aps">All Departments</option>
<option value="search-alias=alexa-skills">Alexa Skills</option>
<option value="search-alias=instant-video">Amazon Video</option>
<option value="search-alias=warehouse-deals">Amazon Warehouse Deals</option>
<option value="search-alias=appliances">Appliances</option>
<option value="search-alias=mobile-apps">Apps & Games</option>
<option value="search-alias=arts-crafts">Arts, Crafts & Sewing</option>
<option value="search-alias=automotive">Automotive Parts & Accessories</option>
<option value="search-alias=baby-products">Baby</option>
<option value="search-alias=beauty">Beauty & Personal Care</option>
<option value="search-alias=stripbooks">Books</option>
<option value="search-alias=popular">CDs & Vinyl</option>
<option value="search-alias=mobile">Cell Phones & Accessories</option>
<option value="search-alias=fashion">Clothing, Shoes & Jewelry</option>
<option value="search-alias=fashion-womens"> Women</option>
<option value="search-alias=fashion-mens"> Men</option>
<option value="search-alias=fashion-girls"> Girls</option>
<option value="search-alias=fashion-boys"> Boys</option>
<option value="search-alias=fashion-baby"> Baby</option>
<option value="search-alias=collectibles">Collectibles & Fine Art</option>
<option value="search-alias=computers">Computers</option>
<option value="search-alias=courses">Courses</option>
<option value="search-alias=financial">Credit and Payment Cards</option>
<option value="search-alias=digital-music">Digital Music</option>
<option value="search-alias=electronics">Electronics</option>
<option value="search-alias=gift-cards">Gift Cards</option>
<option value="search-alias=grocery">Grocery & Gourmet Food</option>
<option value="search-alias=handmade">Handmade</option>
<option value="search-alias=hpc">Health, Household & Baby Care</option>
<option value="search-alias=local-services">Home & Business Services</option>
<option value="search-alias=garden">Home & Kitchen</option>
<option value="search-alias=industrial">Industrial & Scientific</option>
<option value="search-alias=digital-text">Kindle Store</option>
<option value="search-alias=fashion-luggage">Luggage & Travel Gear</option>
<option value="search-alias=luxury-beauty">Luxury Beauty</option>
<option value="search-alias=magazines">Magazine Subscriptions</option>
<option value="search-alias=movies-tv">Movies & TV</option>
<option value="search-alias=mi">Musical Instruments</option>
<option value="search-alias=office-products">Office Products</option>
<option value="search-alias=lawngarden">Patio, Lawn & Garden</option>
<option value="search-alias=pets">Pet Supplies</option>
<option value="search-alias=pantry">Prime Pantry</option>
<option value="search-alias=software">Software</option>
<option value="search-alias=sporting">Sports & Outdoors</option>
<option value="search-alias=tools">Tools & Home Improvement</option>
<option value="search-alias=toys-and-games">Toys & Games</option>
<option value="search-alias=vehicles">Vehicles</option>
<option value="search-alias=videogames">Video Games</option>
<option value="search-alias=wine">Wine</option>
</select>
I need some help ...
I need the location drop down box to determine the appropriate inbox the form should be sent to.
ex if I choose Houston from the drop down box it will send it to the PayrollUSA email.
Im currently using a radio button to make the selection but i would like to automate with the drop down.
Im pretty new to this but im sure theres a if statement that can tie them together...
im using .asp for this.
<input type="radio" name="payroll" value="PayrollUSA#mail.com" checked="checked">US Payroll
<input type="radio" name="payroll" value="PayrollCAN#mail.com">CAN Payroll
<input type="radio" name="payroll" value="PayrollUK#mail.com">UK Payroll
<input type="radio" name="payroll" value="PayrollHK#mail.com">HK Payroll
Drop down selection
<SELECT SIZE="1" NAME="Business_Unit" style="width: 205px;" class="answers">
<option selected >Select</option>
<OPTION>Calgary</OPTION>
<OPTION>Chicago</OPTION>
<OPTION>Hong Kong</OPTION>
<OPTION>Houston</OPTION>
<OPTION>London</OPTION>
<OPTION>Los Angeles</OPTION>
<OPTION>Montreal</OPTION>
<OPTION>New York</OPTION>
<OPTION>New York Corporate</OPTION>
<OPTION>Philadelphia</OPTION>
<OPTION>San Francisco</OPTION>
<OPTION>Toronto</OPTION>
<OPTION>Toronto Corporate</OPTION>
<OPTION>Vancouver</OPTION>
</SELECT>
If you need the option value to be held then try this:
<SELECT SIZE="1" NAME="Business_Unit" style="width: 205px;" class="answers">
<option value="">Select an Option</option>
<option <% if Business_Unit= "PayrollCAN#mail.com" then %> selected <% End if %> value="PayrollCAN#mail.com">Calgary</option>
<option <% if Business_Unit= "PayrollUSA#mail.com" then %> selected <% End if %> value="PayrollUSA#mail.com">Chicago</option>
</select>
etc. for each option and same value may be used for different option displays
I imaging this should just be html based. So your option menu should look like:
<SELECT SIZE="1" NAME="Business_Unit" style="width: 205px;" class="answers">
<option value="-1">Select an Option</option>
<OPTION value="PayrollCAN#mail.com">Calgary</OPTION>
<OPTION value="PayrollUSA#mail.com">Chicago</OPTION>
<OPTION value="PayrollHK#mail.com">Hong Kong</OPTION>
<OPTION value="PayrollUSA#mail.com">Houston</OPTION>
<OPTION value="PayrollUK#mail.com">London</OPTION>
<OPTION value="PayrollUSA#mail.com">Los Angeles</OPTION>
<OPTION value="PayrollCAN#mail.com">Montreal</OPTION>
<OPTION value="PayrollUSA#mail.com">New York</OPTION>
<OPTION value="PayrollUSA#mail.com">New York Corporate</OPTION>
<OPTION value="PayrollUSA#mail.com">Philadelphia</OPTION>
<OPTION value="PayrollUSA#mail.com">San Francisco</OPTION>
<OPTION value="PayrollCAN#mail.com">Toronto</OPTION>
<OPTION value="PayrollCAN#mail.com">Toronto Corporate</OPTION>
<OPTION value="PayrollCAN#mail.com">Vancouver</OPTION>
</SELECT>
You can use the same value multiple times if needed
I have problem with models for example i have
fallBack = models.CharField(max_length=100, choices=FALLBACK, default = 99,blank = True,null = True)
FALLBACK = (
(u'99','-'),
(u'standard', u'Standard TPF deactivation/exlusion applies'),
(u'fallback', u'Fallback script provided'),
(u'na',u'N/A'),
(u'other',u'Other'),
)
if i will use in template
{% for obj in form.forms %}
{{obj.fallBack}}
{% endfor %}
it will return sthing like this
<select name="form-0-fallBack" id="id_form-0-fallBack">
<option value="">---------</option>
<option value="99" selected="selected">-</option>
<option value="standard">Standard TPF deactivation/exlusion applies</option>
<option value="fallback">Fallback script provided</option>
<option value="na">N/A</option>
<option value="other">Other</option>
</select>
But i wanna make something like this:
<select **onchange="javascript:make()"** name="form-0-fallBack" id="id_form-0-fallBack">
<option value="">---------</option>
<option value="99" selected="selected">-</option>
<option value="standard">Standard TPF deactivation/exlusion applies</option>
<option value="fallback">Fallback script provided</option>
<option value="na">N/A</option>
<option value="other">Other</option>
</select>
How to do that ??
I can write in template this secound option instead of {{obj.fallBack}} but then my formset.is_valid() dont work , and when i will do something like this:
1)I will choose from fallBack second option(Standard TPF deactivation/exlusion applies)
2) submit,
3) I have some error in other place in template
4) Then my obj.fallBack returning to default option (99 , -)
Thanks for help
Check out the django documentation on Widgets
widget=forms.Select(attrs={'onchange': 'javascript:make()'})
This looks like a ModelForm, check out how to specify widgets for ModelForms