ChipCoons

ChipCoons

Using Tesla to perform a lookup on a public website

I’m trying to perform a lookup of a public-facing government web site to find licensing information on certain professionals. (See https://secure.utah.gov/liv/search/index.html )

I can load the page using tesla with its mint adaptor but need to now perform a POST, which appears to read part of the form data using JQuery.

The submit button is:

<input type="submit" value="Search" onclick="pageTracker._trackEvent('Search', 'By Name', 'Free'); setProfessions();">

The setProfessions function is:

function setProfessions() {
  $('input:checkbox:checked.licenseType').each(function () {
    $('<input>').attr('type','hidden').attr('value', $(this).val()).attr('name', 'professions').appendTo('form');
  });
}

(It appears the pageTracker._trackEvent script is part of the Google Analytics on the page.)

The request sent over the wire is:

Request
POST /llv/search/search.html HTTP/1.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Origin: https://secure.utah.gov
Cookie: JSESSIONID=fa808df4bb17cee802c57bb3c7d8; TS01bdb7d2=0143bf517010277adab28f63a21b4b94ccd906dc9560f6e061893b1cde8cf4bb926ae1270d0d55201c82143ef6534344f655d9588c6f4af6af8ce1ded94e9257c77dfbee6c; __utma=128287630.1742368486.1591802595.1591810615.1591816490.4; __utmb=128287630.2.9.1591816594569; __utmc=128287630; __utmz=128287630.1591802595.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _ga=GA1.2.1742368486.1591802595; _gat_UA-103830962-11=1; _gid=GA1.2.731830168.1591802595; TS01959f26=0143bf5170cddb06b2628645b42b516df797f7f4f171eee6ee7ff0066afb789be3cef48b9fd7318eeff57bb54412d734fe511bd2f2; __utmt=1; TS01959f26_77=08f156120cab2800bcd2801cf30c2b76e6ce0d21176587d514fd5c1bdd2dae547dca300aea61a5577e55dc465a5d1fa90860c69dd38240003ea72082daf55dd9e6126a7c4ea30f412fef20a05a890c3a4819469b6c38866480328690ce775fcfb40e66968958ccc12126549da8133a87eb122ba58bf2eb55; fontsize=90%25
Accept-Encoding: gzip, deflate, br
Host: secure.utah.gov
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.2 Safari/605.1.15
Accept-Language: en-us
Referer: https://secure.utah.gov/llv/search/index.html
Connection: keep-alive

So it appears the button sends a post to a different URL with the selection from the form.

My question is:
Is there a way to synthetically create the form-data and encode it to be able to send the POST method from within my Phoenix application and then get a response back from the site for parsing?

They do not have a public API, so I’m stuck trying this round-about approach.

If there is a better set of tools to meet this need (other than Tesla), I’m happy to hear recommendations.

Thanks,

First Post!

idi527

idi527

:wave:

Is there a way to synthetically create the form-data and encode it to be able to send the POST method from within my Phoenix application and then get a response back from the site for parsing?

Yes, at least with httpoison, here’s a test case that submits a form.

I haven’t used tesla, but Tesla.Middleware.FormUrlencoded and Tesla.Middleware.FormUrlencodedTest (for examples) might be relevant.

Where Next?

Popular in Questions Top

openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs &amp; Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New

We're in Beta

About us Mission Statement