extract nested dictionary from html - beautifulsoup

I have a html file as described in the picture : kegg mapper result
and I would like to build a table with three columns :"pathway" , "KO" and "Query":
The "Pathway" columns will contain "01100 Metabolic pathway", the "KO" column should contain "K00166" and the "Query" should contain "Trinity_GG_60253_c0_g1_i9.p2"
Here is the html source file
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- saved from url=(0050)https://www.genome.jp/kegg-bin/find_pathway_object -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>KEGG Mapper Reconstruction Result</title>
<meta name="http-equiv" content="Content-Type">
<script type="text/javascript" src="./KEGGResult_files/jquery.min.js.download"></script>
<script type="text/javascript" src="./KEGGResult_files/jquery-ui.min.js.download"></script>
<link rel="stylesheet" type="text/css" href="./KEGGResult_files/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="./KEGGResult_files/mapper2.css">
<script language="JavaScript">
<!---
</style></head>
<body>
<h3>KEGG Mapper Reconstruction Result</h3>
<div class="box1">
<ul class="menu">
<form method="POST" name="form2">
<li class="on">Pathway (4)</li>
<li class="off">Brite (2)</li>
<li class="off">Brite Table (1)</li>
<li class="off">Module (0)</li>
<input type="hidden" name="uploadfile" value="1631631910128046/mapper.args">
<input type="hidden" name="module_complete_file" value="1631631910128046/module_complete.list">
<input type="hidden" name="target" value="">
<input type="hidden" name="pathway_count" value="4">
<input type="hidden" name="brite_count" value="2">
<input type="hidden" name="brite_table_count" value="1">
<input type="hidden" name="module_count" value="0">
<input type="hidden" name="pathway_module_count" value="0">
</form>
</ul>
</div>
<div class="box2">
<form method="POST" name="form1" action="https://www.genome.jp/kegg-bin/find_pathway_object">
<input type="hidden" name="uploadfile" value="1631631910128046/mapper.args">
<input type="hidden" name="module_complete_file" value="1631631910128046/module_complete.list">
<input type="hidden" name="sort" value="object">
<input type="hidden" name="target" value="">
<input type="hidden" name="pathway_count" value="4">
<input type="hidden" name="brite_count" value="2">
<input type="hidden" name="brite_table_count" value="1">
<input type="hidden" name="module_count" value="0">
<input type="hidden" name="pathway_module_count" value="0">
</form>
<p>
</p><div id="all_status">Hide matched objects</div>
<p>
</p><div id="list">
<!-- -->
<b>Metabolism</b>
<ul>
Global and overview maps
<ul>
<li>01100 Metabolic pathways (1)
<div id="objectmap01100" class="object" style="display: inline;"><p>
</p><dl>
<dt>K00166</dt>
<dd>Trinity_GG_60253_c0_g1_i9.p2</dd>
</dl>
</div></li><li>01110 Biosynthesis of secondary metabolites (1)
<div id="objectmap01110" class="object" style="display: inline;"><p>
</p><dl>
<dt>K00166</dt>
<dd>Trinity_GG_60253_c0_g1_i9.p2</dd>
</dl>
</div></li> </ul>
Carbohydrate metabolism
<ul>
<li>00640 Propanoate metabolism (1)
<div id="objectmap00640" class="object" style="display: inline;"><p>
</p><dl>
<dt>K00166</dt>
<dd>Trinity_GG_60253_c0_g1_i9.p2</dd>
</dl>
</div></li> </ul>
Amino acid metabolism
<ul>
<li>00280 Valine, leucine and isoleucine degradation (1)
<div id="objectmap00280" class="object" style="display: inline;"><p>
</p><dl>
<dt>K00166</dt>
<dd>Trinity_GG_60253_c0_g1_i9.p2</dd>
</dl>
</div></li></ul></ul></div></div>
</body></html>

I have taken your data as HTML and find text according to tag wise
first one Metabolic... it is outside tag so i have find out next tag for it and then previous text from the methods
soup=BeautifulSoup(html,"lxml")
data=soup.find_all("li")
lst=[]
for i in data:
data_lst=[]
data_lst.append(i.find("a").find_next().previous.replace("("," "))
data_lst.append(i.find("dt").get_text())
data_lst.append(i.find("dd").get_text())
lst.append(data_lst)
import pandas as pd
df=pd.DataFrame(columns=["Pathway","KO","Query"],data=lst)
Output:
Pathway KO Query
0 Metabolic pathways K00166 Trinity_GG_60253_c0_g1_i9.p2
1 Biosynthesis of secondary metabolites K00166 Trinity_GG_60253_c0_g1_i9.p2
2 Propanoate metabolism K00166 Trinity_GG_60253_c0_g1_i9.p2
3 Valine, leucine and isoleucine degradation K00166 Trinity_GG_60253_c0_g1_i9.p2

Related

Centering Mailchimp Embed Form on Shopify

I'm trying to center an entire embedded Mailchimp form in my nonprofit's Shopify but after trying a few things I'm not sure how to do this properly.
Code below:
<!-- Begin Mailchimp Signup Form -->
<link href="//cdn-images.mailchimp.com/embedcode/classic-10_7.css" rel="stylesheet" type="text/css">
<style type="text/css">
#mc_embed_signup{background:#fff; clear:center; font:14px Helvetica,Arial,sans-serif; width:600px;}
/* Add your own Mailchimp form style overrides in your site stylesheet or in this style block.
We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */
</style>
<div id="mc_embed_signup">
<form action="https://caffelena.us6.list-manage.com/subscribe/post?u=46238df01d2ba6f28a9a0f68d&id=e2eee316a5" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<h2>Subscribe To Our Mailing List!</h2>
<div class="indicates-required"><span class="asterisk">*</span> indicates required</div>
<div class="mc-field-group">
<label for="mce-EMAIL">Email Address <span class="asterisk">*</span>
</label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>
<div class="mc-field-group">
<label for="mce-FNAME">First Name </label>
<input type="text" value="" name="FNAME" class="" id="mce-FNAME">
</div>
<div class="mc-field-group">
<label for="mce-LNAME">Last Name </label>
<input type="text" value="" name="LNAME" class="" id="mce-LNAME">
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div> <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
<div style="position: absolute; center: -5000px;" aria-hidden="true"><input type="text" name="b_46238df01d2ba6f28a9a0f68d_e2eee316a5" tabindex="-1" value=""></div>
<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
</div>
</form>
</div>
<!--End mc_embed_signup-->

asp.net core binder doesn't work if object have more than 20 properties 0_o

I have .cshtml page , it has model List
Class Indications have 20 properties. My form
#model List<Indications>
<body>
<div>
<form asp-action="EditFlatLight" asp-controller="Home" method="post" enctype="multipart/form-data" class="container">
#for (int i=0; i<Model.Count();i++)
{
var indication = Model[i].GetType().GetProperty(ViewBag.Title).GetValue(Model[i], null).ToString();
var data = ViewBag.Title;
<div class="row">
<div class="column">
<label>#Model[i].FlatNumber</label>
</div>
<div class="column">
<input type="text" class="row" value="#indication" asp-for="#Model[i].Month" tabIndex="#i">
</div>
<div class="column">
<input type="hidden" value="#ViewBag.Title" asp-for="#Model[i].Type"/>
</div>
<div class="column">
<input type="hidden" value="#Model[i].Id" asp-for="#Model[i].Id"/>
</div>
<div class="column">
<input type="hidden" value="#Model[i].Login" asp-for="#Model[i].Login"/>
</div>
<div class="column">
<input type="hidden" value="#Model[i].City" asp-for="#Model[i].City"/>
</div>
<div class="column">
<input type="hidden" value="#Model[i].Street" asp-for="#Model[i].Street"/>
</div>
<div class="column">
<input type="hidden" value="#Model[i].HouseNumber" asp-for="#Model[i].HouseNumber"/>
</div>
<div class="column">
<input type="hidden" value="#Model[i].January" asp-for="#Model[i].January"/>
</div>
<div class="column">
<input type="hidden" value="#Model[i].February" asp-for="#Model[i].February"/>
</div>
<div class="column">
<input type="hidden" value="#Model[i].March" asp-for="#Model[i].March"/>
</div>
<div class="column">
<input type="hidden" value="#Model[i].April" asp-for="#Model[i].April"/>
</div>
<div class="column">
<input type="hidden" value="#Model[i].May" asp-for="#Model[i].May"/>
</div>
<div class="column">
<input type="hidden" value="#Model[i].June" asp-for="#Model[i].June"/>
</div>
<div class="column">
<input type="hidden" value="#Model[i].July" asp-for="#Model[i].July"/>
</div>
<div class="column">
<input type="hidden" value="#Model[i].August" asp-for="#Model[i].August"/>
</div>
<div class="column">
<input type="hidden" value="#Model[i].September" asp-for="#Model[i].September"/>
</div>
<div class="column">
<input type="hidden" value="#Model[i].October" asp-for="#Model[i].October"/>
</div>
<div class="column">
<input type="hidden" value="#Model[i].November" asp-for="#Model[i].November"/>
</div>
<div class="column">
<input type="hidden" value="#Model[i].December" asp-for="#Model[i].December"/>
</div>
</div>
}
<button id="btnSave" class="btn btn-success" style="margin-right:5px">Save</button>
</form>
</div>
</body>
And if i try to pass data to controller with all parameters it return null, but if try to pass least than 20 parameters, i receive full list, please, help....
Controller code:
[HttpPost]
public async Task<IActionResult> Edit(IEnumerable<Indications> newData)
{
}
I fight with this problem whole week. I really don't understand why i get null with more than 20 properties 0_0

Undefined variable: errors in blade view laravel 8x

This is my view file and my controller file
View file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-http-equiv="X-UA-Compatible" content="ie=edge">
<title>Register page</title>
</head>
<body>
<div class="container">
<div class="row" style="margin-top:45px">
<div class="col-md-4 col-md-offset-4">
<h4>Register | Custom Auth</h4><hr>
<form action="{{ route('auth.save') }}" method="post">
#if(Session::get('success'))
<div class="alert alert-success">
{{ Session::get('success') }}
</div>
#endif
#if(Session::get('fail'))
<div class="alert alert-danger">
{{ Session::get('fail') }}
</div>
#endif
#csrf
<div class="form-group">
<label>Username</label>
<input type="text" class="form-control" name="username" placeholder="Enter username here" value="{{ old('username') }}">
<span class="text-danger">#error('username'){{ $message }} #enderror</span>
</div>
<div class="form-group">
<label>Password</label>
<input type="password" class="form-control" name="password" placeholder="Enter password here">
<span class="text-danger">#error('password'){{ $message }} #enderror</span>
</div>
<div class="form-group">
<label>Phonenumber</label>
<input type="tel" class="form-control" name="phonenumber" placeholder="Enter phonenumber here" value="{{ old('phonenumber') }}">
<span class="text-danger">#error('phonenumber'){{ $message }} #enderror</span>
</div>
<button type="submit" class="btn btn-block btn-primary">Sign up</button>
<br>
I already have an account, sign in
</form>
</div>
</div>
</div>
</body>
</html>
Api file
Route::post('/auth/save', [MainController::class, 'save'])->name('auth.save');
Route::post('/auth/check', [MainController::class, 'check'])->name('auth.check');
Route::get('/auth/logout', [MainController::class, 'logout'])->name('auth.logout');
Route::group(['middleware'=>['AuthCheck']], function(){
Route::get('/auth/login', [MainController::class, 'login'])->name('auth.login');
Route::get('/auth/register', [MainController::class, 'register'])->name('auth.register');
Route::get('/client/dashboard', [MainController::class, 'dashboard']);
});
This is my Rest API and blade file.I have the error Undefined variable: errors, but i cant find where is the problem. Can anyone help me ? I search maybe there is a problem in kernel config, but i everything is fine.*

csrfToken() is not working with html page?

I am having node js backened server and frontend is simple html file running as a spa server.
<h1>Hello World</h1>
<form action="http://localhost:3000/entry" method="POST">
<div>
<label for="message">Enter a message</label>
<input id="message" name="message" type="text" />
</div>
<input type="submit" value="Submit" />
<input type="hidden" name="_csrf" value="{{csrfToken()}}" />
</form>
But it is not working.

Aligning two forms and other buttons inline

I have two forms, each form has multiple hidden fields and a submit button.
My goal is to align those forms with two other normal buttons horizontally (inline) using bootstrap.
Here's what I've tried so far:
<div class="container">
<div class="row">
<div class="col-xs-6">
<a class="btn btn-primary" href="/employees/new">Add new Employee</a>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">Search</button>
<form class="form-inline" action="../reports/pdf/employees" method="GET">
<input type="hidden" id="column" th:if="${param.column !=null}" name="column" th:value="${param.column}">
<input type="hidden" th:if="${param.sort == null}" id="sort" name="sort" value="ASC">
<input type="hidden" th:if="${param.sort != null}" id="sort" name="sort" th:value="${param.sort}">
<input type="hidden" th:if="${param.name!=null}" name="name" id="id" th:value="${param.name}">
<input type="hidden" th:if="${param.surname!=null}" name="surname" id="surname" th:value="${param.surname}">
<input type="hidden" th:if="${param.hiredate!=null}" name="hiredate" id="hiredate" th:value="${param.hiredate}">
<input type="hidden" th:if="${param.birthdate!=null}" name="birthdate" id="birthdate" th:value="${param.birthdate}">
<input type="hidden" th:if="${param.email!=null}" name="email" id="email" th:value="${param.email}">
<input type="hidden" th:if="${param.address!=null}" name="address" id="address" th:value="${param.address}">
<input type="hidden" th:if="${param.phone!=null}" name="phone" id="phone" th:value="${param.phone}">
<button class="btn btn-primary" type="submit">Print pdf report</button>
</form>
<form action="../reports/csv/employees" method="GET">
<input type="hidden" id="column" th:if="${param.column !=null}" name="column" th:value="${param.column}">
<input type="hidden" th:if="${param.sort == null}" id="sort" name="sort" value="ASC">
<input type="hidden" th:if="${param.sort != null}" id="sort" name="sort" th:value="${param.sort}">
<input type="hidden" th:if="${param.name!=null}" name="name" id="id" th:value="${param.name}">
<input type="hidden" th:if="${param.surname!=null}" name="surname" id="surname" th:value="${param.surname}">
<input type="hidden" th:if="${param.hiredate!=null}" name="hiredate" id="hiredate" th:value="${param.hiredate}">
<input type="hidden" th:if="${param.birthdate!=null}" name="birthdate" id="birthdate" th:value="${param.birthdate}">
<input type="hidden" th:if="${param.email!=null}" name="email" id="email" th:value="${param.email}">
<input type="hidden" th:if="${param.address!=null}" name="address" id="address" th:value="${param.address}">
<input type="hidden" th:if="${param.phone!=null}" name="phone" id="phone" th:value="${param.phone}">
<button class="btn btn-primary" type="submit">Print csv report</button>
</form>
</div>
fix: add form-inline to second form
NB:
forms are block items - change to inline-block via css or style.
buttons still wrap, may need to change col-xs-6 to something wider
form.form-inline {
display: inline-block
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-xs-12">
<a class="btn btn-primary" href="/employees/new">Add new Employee</a>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">Search</button>
<form class="form-inline" action="../reports/pdf/employees" method="GET">
<input type="hidden" id="column" th:if="${param.column !=null}" name="column" th:value="${param.column}">
<input type="hidden" th:if="${param.sort == null}" id="sort" name="sort" value="ASC">
<input type="hidden" th:if="${param.sort != null}" id="sort" name="sort" th:value="${param.sort}">
<input type="hidden" th:if="${param.name!=null}" name="name" id="id" th:value="${param.name}">
<input type="hidden" th:if="${param.surname!=null}" name="surname" id="surname" th:value="${param.surname}">
<input type="hidden" th:if="${param.hiredate!=null}" name="hiredate" id="hiredate" th:value="${param.hiredate}">
<input type="hidden" th:if="${param.birthdate!=null}" name="birthdate" id="birthdate" th:value="${param.birthdate}">
<input type="hidden" th:if="${param.email!=null}" name="email" id="email" th:value="${param.email}">
<input type="hidden" th:if="${param.address!=null}" name="address" id="address" th:value="${param.address}">
<input type="hidden" th:if="${param.phone!=null}" name="phone" id="phone" th:value="${param.phone}">
<button class="btn btn-primary" type="submit">Print pdf report</button>
</form>
<form class="form-inline" action="../reports/csv/employees" method="GET">
<input type="hidden" id="column" th:if="${param.column !=null}" name="column" th:value="${param.column}">
<input type="hidden" th:if="${param.sort == null}" id="sort" name="sort" value="ASC">
<input type="hidden" th:if="${param.sort != null}" id="sort" name="sort" th:value="${param.sort}">
<input type="hidden" th:if="${param.name!=null}" name="name" id="id" th:value="${param.name}">
<input type="hidden" th:if="${param.surname!=null}" name="surname" id="surname" th:value="${param.surname}">
<input type="hidden" th:if="${param.hiredate!=null}" name="hiredate" id="hiredate" th:value="${param.hiredate}">
<input type="hidden" th:if="${param.birthdate!=null}" name="birthdate" id="birthdate" th:value="${param.birthdate}">
<input type="hidden" th:if="${param.email!=null}" name="email" id="email" th:value="${param.email}">
<input type="hidden" th:if="${param.address!=null}" name="address" id="address" th:value="${param.address}">
<input type="hidden" th:if="${param.phone!=null}" name="phone" id="phone" th:value="${param.phone}">
<button class="btn btn-primary" type="submit">Print csv report</button>
</form>
</div>
</div>
</div>
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
form.form-inline {
display: inline-block
}
</style>
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please upgrade your browser to improve your experience.</p>
<![endif]-->
<div class="container">
<div class="row">
<div class="col-xs-12">
<a class="btn btn-primary" href="/employees/new">Add new Employee</a>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">Search</button>
<form class="form-inline" action="../reports/pdf/employees" method="GET">
<input type="hidden" id="column" th:if="${param.column !=null}" name="column" th:value="${param.column}">
<input type="hidden" th:if="${param.sort == null}" id="sort" name="sort" value="ASC">
<input type="hidden" th:if="${param.sort != null}" id="sort" name="sort" th:value="${param.sort}">
<input type="hidden" th:if="${param.name!=null}" name="name" id="id" th:value="${param.name}">
<input type="hidden" th:if="${param.surname!=null}" name="surname" id="surname" th:value="${param.surname}">
<input type="hidden" th:if="${param.hiredate!=null}" name="hiredate" id="hiredate" th:value="${param.hiredate}">
<input type="hidden" th:if="${param.birthdate!=null}" name="birthdate" id="birthdate" th:value="${param.birthdate}">
<input type="hidden" th:if="${param.email!=null}" name="email" id="email" th:value="${param.email}">
<input type="hidden" th:if="${param.address!=null}" name="address" id="address" th:value="${param.address}">
<input type="hidden" th:if="${param.phone!=null}" name="phone" id="phone" th:value="${param.phone}">
<button class="btn btn-primary" type="submit">Print pdf report</button>
</form>
<form class="form-inline"action="../reports/csv/employees" method="GET">
<input type="hidden" id="column" th:if="${param.column !=null}" name="column" th:value="${param.column}">
<input type="hidden" th:if="${param.sort == null}" id="sort" name="sort" value="ASC">
<input type="hidden" th:if="${param.sort != null}" id="sort" name="sort" th:value="${param.sort}">
<input type="hidden" th:if="${param.name!=null}" name="name" id="id" th:value="${param.name}">
<input type="hidden" th:if="${param.surname!=null}" name="surname" id="surname" th:value="${param.surname}">
<input type="hidden" th:if="${param.hiredate!=null}" name="hiredate" id="hiredate" th:value="${param.hiredate}">
<input type="hidden" th:if="${param.birthdate!=null}" name="birthdate" id="birthdate" th:value="${param.birthdate}">
<input type="hidden" th:if="${param.email!=null}" name="email" id="email" th:value="${param.email}">
<input type="hidden" th:if="${param.address!=null}" name="address" id="address" th:value="${param.address}">
<input type="hidden" th:if="${param.phone!=null}" name="phone" id="phone" th:value="${param.phone}">
<button class="btn btn-primary" type="submit">Print csv report</button>
</form>
</div>
<script src="" async defer></script>
</body>
</html>
see it ijn full screen