B
B
Bjornie2016-12-11 23:54:43
Python
Bjornie, 2016-12-11 23:54:43

How to parse multilevel forms?

There is a three-level form, like:

--- Select1:
  option_1
  option_2
  option_...
  option_50
--- Select2:
  option_1
  option_2
  option_...
  option_35
--- Select3:
  option_a
  option_b
  option_...
  option_z

Those. there are a lot of possible combinations. After opening the results on each page, I get a list of the links I need, which later also need to be traversed and parsed (this has already been implemented).
Question: how to work with such forms? For example: if there are 1000 combinations. How can I go through them all?
I will add that all forms are loaded by ajax, and the result pages are generated by the system, i.e. I can not pick up the results by substituting parameters in the request.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
angru, 2016-12-12
@Bjornie

If the elements of the selects can be arbitrarily combined with each other, i.e. each with each, then everything is very simple, we get the form data, no matter how, a simple or ajax request, we combine all the elements, then we send a request for each combination. piece of code to understand the principle:

print([[x, y, z] for x in range(3) for y in range(3) for z in range(3)])

# ну или на привычных циклах
res = []

for x in range(3):
    for y in range(3):
        for z in range(3):
            res.append([x, y, z])

print(res)

If the elements are combined according to certain rules, you need to build some combination graph.

D
Dimonchik, 2016-12-11
@dimonchik2013

working with AJAX +
While - if you can't
For - if you can
pick up the parameters

A
Alexey Sundukov, 2016-12-12
@alekciy

Do the values ​​for Select2 depend on the selected option in Select1? Do Select3 values ​​depend on the selected option in Select2? It is possible stupidly by a banal enumeration method.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question