88102

Select radio buttons with scrapy

Question:

How would i go about selection radio buttons with scrapy?

I am trying to select the following

formdata={'rd1':'E'} does not work <input type="radio" name="rd1" value="E" checked="checked" />Employee <input type="radio" name="rd2" value="o" />Other

Answer1:

You could use <a href="http://lxml.de/cssselect.html" rel="nofollow">lxml.cssselector</a> to select the radio buttons.

>>> import lxml.html >>> from lxml.cssselect import CSSSelector >>> str = """ ... '<input type="radio" name="rd1" value="E" checked="checked" />Employee ... <input type="radio" name="rd2" value="o" />Other' ... """ >>> input_sel = CSSSelector('input[name="rd1"]') >>> lx = lxml.html.fromstring(str) >>> input_sel(lx) [<InputElement b7e7665c name='rd1' type='radio'>]

Recommend

  • Changing one activity to another using RadioButton
  • Application Express: Anonymous PL/SQL Block and Bind Variables
  • UWP - Show textbox text highlight while textbox is out of focus
  • Making a multi-line select box read-only in HTML
  • Why does IE8 fail to resolve my JQuery selector for a checked radio option?
  • How to use tag-it
  • Javascript focus remove text highlight
  • Select value from xtype selection type checkbox CQ5
  • Flash radiobutton: how do I get the selected radiobutton?
  • Error in installing package: fatal error: stdlib.h: no such file or directory
  • How can I restyle a word when rendering a pdf with pdf.js?
  • How to make R's read_csv2() recognise the text characters properly
  • How do I display a dialog that asks the user multi-choice questıon using tkInter?
  • Conversion from string “a” to type 'Boolean' is not valid
  • Android full screen on only one activity?
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • Deselecting radio buttons while keeping the View Model in synch
  • Nant, Vault & Windows Integrated Authentication
  • what is the difference between the asp.net mvc application and asp.net web application
  • Adding custom controls to a full screen movie
  • R: gsub and capture
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • VB.net deserialize, JSON Conversion from type 'Dictionary(Of String,Object)' to type '
  • Data Validation Drop Down Box Arrow Disappearing
  • Comma separated Values
  • Matrix multiplication with MKL
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • How do you join a server to an Active Directory (domain)?
  • How do I configure my settings file to work with unit tests?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Easiest way to encapsulate a HTML5 webpage into an android app?
  • Busy indicator not showing up in wpf window [duplicate]
  • costura.fody for a dll that references another dll
  • Binding checkboxes to object values in AngularJs
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal
  • How to load view controller without button in storyboard?