Reputation: 33
I am quite new to webscraping so I am having a trouble automatically filling in forms. Below is the relevant python code and html source code of the webpage. So, what I am trying to do is to fill forms that do not have 'name' attribute but have 'class' attribute. But python gives me an error.
brw = ms.StatefulBrowser()
brw.open("http://www.krisha.kz")
brw.select_form('form[action="/prodazha/kvartiry/"]')
brw.get_current_form().print_summary()
brw["category-type"]="rent"
brw.submit_selected()
brw.get_url()
<form id="search-form" action="/prodazha/kvartiry/" method="get">
<div class="search-block-inputs">
<div class="search-block-form search-block-category">
<div class="search-element-wrap">
<div class="element-select">
<select class="category-type">
<option data-alias="prodazha" value="sell" selected>Купить</option>
<option data-alias="arenda" value="rent" >Снять</option>
</select>
<svg role="img" class="icon icon-svg icon-arrow-down"><use xlink:href="#icon-arrow-down"></use></svg>
</div>
</div>
<div class="search-element-wrap categories-for-sell">
<div class="element-select">
<select>
<option value="" data-alias="kvartiry" selected="selected">квартиру</option>
<option value="" data-alias="doma">дом</option>
<option value="" data-alias="dachi">дачу</option>
<option value="" data-alias="uchastkov">участок</option>
<option value="" data-alias="ofisa">офис</option>
<option value="" data-alias="pomeshhenija">помещение</option>
<option value="" data-alias="zdanija">здание</option>
<option value="" data-alias="magazina">магазин, бутик</option>
<option value="" data-alias="prombazy">промбазу, склад</option>
<option value="" data-alias="prochej-nedvizhimosti">прочее</option>
</select>
<svg role="img" class="icon icon-svg icon-arrow-down"><use xlink:href="#icon-arrow-down"></use></svg>
</div>
</div>
Python gives me an error "LinkNotFoundError: No valid element named category-type". Can you please help me to figure out how to fill with no 'name' attributes? Also, there are some items that do not have attributes at all, so how to deal with them?
Thank you in advance!
Upvotes: 3
Views: 914