Yahoo Finance IndexError: list index out of range - xpath

I grab prices from Yahoo Finance using the code below. Worked fine until recently. The code still runs but returns no value instead telling me: IndexError: list index out of range.
I tried to reset the xpath to no avail. Thoughts on how to make it work?
import lxml.etree
import urllib.parse as urlparse
import requests
def parse_url(url):
tree = lxml.etree.fromstring(url, parser=lxml.etree.HTMLParser())
tree.xpath('.//table[#class="W(100%)"]')
return tree
if __name__ == "__main__":
urlivv = requests.get('http://finance.yahoo.com/q?s=IVV').text
docivv = parse_url(urlivv)
priceivv = docivv.xpath('//*[#id="quote-header-info"]/div[3]/div[1]/div/span[1]//text()')
ivv = priceivv[0]

Taking a look at what urlivv contains, I do not believe the information you want is in the html you're working with.
In [6]: urlivv
Out[6]: '<!DOCTYPE html>\n <html lang="en-us"><head>\n <meta http-equiv="content-type" content="text/html; charset=UTF-8">\n <meta charset="utf-8">\n <title>Yahoo</title>\n <meta name="viewport" content="width=device-width,initial-scale=1,minimal-ui">\n <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">\n <style>\n html {\n height: 100%;\n }\n body {\n background: #fafafc url(https://s.yimg.com/nn/img/sad-panda-201402200631.png) 50% 50%;\n background-size: cover;\n height: 100%;\n text-align: center;\n font: 300 18px "helvetica neue", helvetica, verdana, tahoma, arial, sans-serif;\n }\n table {\n height: 100%;\n width: 100%;\n table-layout: fixed;\n border-collapse: collapse;\n border-spacing: 0;\n border: none;\n }\n h1 {\n font-size: 42px;\n font-weight: 400;\n color: #400090;\n }\n p {\n color: #1A1A1A;\n }\n #message-1 {\n font-weight: bold;\n margin: 0;\n }\n #message-2 {\n display: inline-block;\n *display: inline;\n zoom: 1;\n max-width: 17em;\n _width: 17em;\n }\n </style>\n <script>\n document.write(\'<img src="//geo.yahoo.com/b?s=1197757129&t=\'+new Date().getTime()+\'&src=aws&err_url=\'+encodeURIComponent(document.URL)+\'&err=%<pssc>&test=\'+encodeURIComponent(\'%<{Bucket}cqh[:200]>\')+\'" width="0px" height="0px"/>\');var beacon = new Image();beacon.src="//bcn.fp.yahoo.com/p?s=1197757129&t="+new Date().getTime()+"&src=aws&err_url="+encodeURIComponent(document.URL)+"&err=%<pssc>&test="+encodeURIComponent(\'%<{Bucket}cqh[:200]>\');\n </script>\n </head>\n <body>\n <!-- status code : 404 -->\n <!-- Not Found on Server -->\n <table>\n <tbody><tr>\n <td>\n <img src="https://s.yimg.com/rz/p/yahoo_frontpage_en-US_s_f_p_205x58_frontpage.png" alt="Yahoo Logo">\n <h1 style="margin-top:20px;">Will be right back...</h1>\n <p id="message-1">Thank you for your patience.</p>\n <p id="message-2">Our engineers are working quickly to resolve the issue.</p>\n </td>\n </tr>\n </tbody></table>\n </body></html>'

Related

laravel loadview pdf output not same as html

please i need help
i have my html code which working very fine ,and trying to loadview it as pdf stream
but the output pdf file , not same as html , and text not above image , but get below it
my controller code
public function pdfdownload($id)
{
$id = Crypt::decrypt($id);
$course = Course::where('id', $id)->first();
$orders = Order::where('course_id', $id)->first();
$progress = CourseProgress::where('course_id', $course->id)->where('user_id', Auth::user()->id)->first();
$pdf = PDF::loadView('front.certificate.download', compact('course', 'progress'), [],
[
'title' => 'Certificate',
'orientation' => 'L'
]);
// return $pdf->download('certificate.pdf');
return $pdf->stream('certificate.pdf');
}
my html code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style type="text/css" media="all">
#import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
body{
margin: 0;
box-sizing: border-box;
font-family: 'Roboto', sans-serif;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
h1,h2,h3,h4,h5,h6{
margin: 0 0 15px;
}
.certificate-wrapper{
max-width: 910px;
border: 1px solid #007B83;
}
.certificate-wraper img {
max-width: 100%;
}
/* certificate Antipasto Pro */
.certificate_content {
position: absolute;
top: 182px;
right: 29px;
width: 480px;
}
.certificate_content h2 {
font-size: 29px;
text-transform: uppercase;
color: #29AFA7;
margin-top: 10px;
}
.certificate_content h3 {
text-transform: uppercase;
color: #29AFA7;
font-size: 21px;
}
.certificate_content span {
text-transform: uppercase;
}
.prisciples {
font-size: 25px;
margin-top: 39px;
}
.credit {
margin-top: 27px;
}
.prof {
margin-top: 28px;
}
.date_time {
display: block;
margin-top: 66px;
margin-left: 99px;
color: #000;
font-size: 18px;
}
.code {
margin-top: 22px;
display: block;
margin-left: 83px;
font-size: 14px;
}
/* certificate-end */
.position-relative{
position: relative;
}
</style>
</head>
<body>
<div class="certificate-wrapper">
<div class="certificate-wraper position-relative certificater-img">
<img src="certi-main-bg.png" alt="">
<div class="certificate_content">
<h2>Basma sherif abd alwahab</h2>
<h3 class="prisciples">Principles of Dento-alveolar Surgery
with Live Demo on Suture Techniques</h3>
<h3 class="credit">2 creidt hours</h3>
<h3 class="prof">Prof.Ahmed Elsharkawy</h3>
<div class="certi_abs_content">
<span class="date_time"> april</span>
<span class="code">code</span>
</div>
</div>
</div>
</div>
</body>
</html>
that how img show in html page
html view
that's how pdf stream output looks like
pdf stream
please i would really appreciates any help
, how to solve that
and why pdf not view same as html >?
I think your main issue is that laravel-pdf is a wrapper for mPDF which does not support flex.
See this list for css that is supported: https://mpdf.github.io/css-stylesheets/supported-css.html

Having trouble importing my csv data into a table using D3

Apologies if this is rudimentary but I am new to D3. I'm having trouble importing my csv data and displaying it as a table that can be opened in a browser. All my data files and code are located in the same folder. Here is the code I have so far and my csv data. Any advice is greatly appreciated!
SublimeFile.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
<title>Dashboard</title>
<link rel="stylesheet" href="normalize.css">
<style>
table {
border-collapse: collapse;
border: 2px grey solid;
font: 12px sans-serif;
}
td {
border: 1px grey solid;
padding: 5px;
}
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
margin-left:40px;
font-weight: 200;
font-size: 16px;
}
h1 {font-weight: 400;}
p {font-size: 12px;}
text {font-size: 12px;}
</style>
</head>
<body>
<div id = "Chart"></div>
<script>
d3.text("dashboard.csv", function(data) {
var parsedCSV = d3.csv.parseRows(data);
var container = d3.select("body")
.append("table")
.selectAll("tr")
.data(parsedCSV).enter()
.append("tr")
.selectAll("td")
.data(function(d) { return d; }).enter()
.append("td")
.text(function(d) { return d; });
});
</script>
</body>
</html>
dashboard.csv
Entity,Entity A
Head of Data,Albert Aldridge
DG Lead,Anna Annovo
BIO,April Autumn
Business Participants,"Alfred, Adeline, Amy"
Scope,European Platforms
Scope Trend,Steady
Thanks for your efforts, I was able to figure it out. I was trying to run the .html file in chrome & internet explorer with no luck. It seems to only work in firefox for me.

how to get particular search result in elastic using jest with spring mvc

here is my sample code but able get values but there may be a issue plz help me
when i search in search form i need that particular result..
#Controller
public class SearchController {
ModelAndView mv;
SearchModel log;
#RequestMapping("/Search.htm")
public #ResponseBody ModelAndView getSearchModelList() throws Exception
{
String clusterIP = "localhost";
String port = "9200";
//setup client
JestClientFactory factory = new JestClientFactory();
factory.setHttpClientConfig(new HttpClientConfig
.Builder("http://" + clusterIP + ":" + port)
.multiThreaded(true)
.build());
JestClient client = factory.getObject();
Search search = new Search.Builder("{ \"query\": { \"match\": {} } }")
.addIndex("eix")
.addType("articles")
.build();
//results print here
JestResult result = client.execute(search);
List<SearchModel> resultLogs = result.getSourceAsObjectList(SearchModel.class);
for(SearchModel log: resultLogs){
System.out.println(log);
mv.addObject("log", log);
}
return mv;
}}
and here my jsp code.just print search form
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Eix</title>
<style type="text/css">
#tfheader{
background-color:#c3dfef;
}
#tfnewsearch{
float:right;
padding:20px;
}
.tftextinput{
margin: 0;
padding: 5px 15px;
font-family: Arial, Helvetica, sans-serif;
font-size:14px;
border:1px solid #0076a3; border-right:0px;
border-top-left-radius: 5px 5px;
border-bottom-left-radius: 5px 5px;
}
.tfbutton {
margin: 0;
padding: 5px 15px;
font-family: Arial, Helvetica, sans-serif;
font-size:14px;
outline: none;
cursor: pointer;
text-align: center;
text-decoration: none;
color: #ffffff;
border: solid 1px #0076a3; border-right:0px;
background: #0095cd;
background: -webkit-gradient(linear, left top, left bottom, from(#00adee), to(#0078a5));
background: -moz-linear-gradient(top, #00adee, #0078a5);
border-top-right-radius: 5px 5px;
border-bottom-right-radius: 5px 5px;
}
.tfbutton:hover {
text-decoration: none;
background: #007ead;
background: -webkit-gradient(linear, left top, left bottom, from(#0095cc), to(#00678e));
background: -moz-linear-gradient(top, #0095cc, #00678e);
}
/* Fixes submit button height problem in Firefox */
.tfbutton::-moz-focus-inner {
border: 0;
}
.tfclear{
clear:both;
}
</style>
</head>
<body>
<form id="tfnewsearch" method="post" action="Search.htm">
<input type="text" class="tftextinput" name="q" size="21" maxlength="120">
<input type="submit" value="search" class="tfbutton">
</form>
<div class="tfclear"></div>
</body>
</html>
and here print search values in this jsp..
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Eix</title>
<style type="text/css">
</style>
</head>
<body>
<h2>${log}</h2>
</body>
</html>

new, deploy, jssdk return 404

I got error when I tried to create CouldCode by using
$parse new CloudCode
parse: error with status=404 and body="<!DOCTYPE html>\n<html>\n\n<head>\n <title>404 | Parse</title>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\">\n <meta charset=\"utf-8\">\n <style type=\"text/css\">\n html{\n -webkit-font-smoothing: antialiased;\n text-rendering: optimizeLegibility; \n }\n html,\n body,\n .four_oh_four {\n padding: 0px;\n margin: 0px;\n height: 100%;\n width: 100%;\n }\n .four_oh_four {\n background-image: -o-linear-gradient(-38deg, #1AB5C2 0%, #0572E0 100%);\n background-image: -moz-linear-gradient(-38deg, #1AB5C2 0%, #0572E0 100%);\n background-image: -ms-linear-gradient(-38deg, #1AB5C2 0%, #0572E0 100%);\n background-image: linear-gradient(128deg, #1AB5C2 0%, #0572E0 100%);\n font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n color: #fff;\n }\n .four_oh_four .logo {\n display: block;\n margin: 0 auto;\n top: 50px;\n position: relative;\n }\n .four_oh_four .nav {\n list-style: none;\n font-weight: 200;\n font-size: 18px;\n margin: 0 auto;\n position: absolute;\n padding: 0;\n bottom: 50px;\n width: 100%;\n text-align: center;\n }\n .four_oh_four .nav li {\n display: inline-block;\n margin: 0px 10px;\n }\n .four_oh_four .nav a {\n color: #fff;\n text-decoration: none;\n }\n .four_oh_four .nav a:hover {\n text-decoration: underline;\n }\n .four_oh_four .error {\n display: block;\n position: absolute;\n top: 50%;\n -moz-transform: translateY(-50%); \n -webkit-transform: translateY(-50%);\n transform: translateY(-50%);\n margin: 0;\n padding: 0;\n text-align: center;\n width: 100%;\n }\n .four_oh_four h1 {\n font-weight: 100;\n font-size: 240px;\n margin: 0;\n padding: 0;\n }\n .four_oh_four h2 {\n font-weight: 200;\n font-size: 28px;\n margin: 0;\n padding: 0;\n }\n .four_oh_four #emoji {\n position: relative;\n top: 40px;\n background-image: url('/images/404/sprite.png');\n display: inline-block;\n width: 200px;\n height: 230px;\n background-size: 6000px;\n background-repeat: no-repeat;\n }\n #media (max-width: 500px) {\n .four_oh_four .logo {\n top: 30px;\n }\n .four_oh_four h1 {\n font-size: 120px;\n }\n .four_oh_four h2 {\n font-size: 22px;\n }\n .four_oh_four #emoji {\n width: 100px;\n height: 115px;\n top: 16px;\n background-size: 3000px;\n }\n .four_oh_four .nav {\n bottom: 30px;\n }\n .four_oh_four .nav li {\n margin: 5px 14px;\n }\n }\n </style>\n <script>\n var emojiCount = 30;\n function getRandomInt(min, max) {\n return Math.floor(Math.random() * (max - min + 1)) + min;\n }\n\n\n function catchFeelings() {\n var emoji = getRandomInt(0, emojiCount - 1)\n if(window.innerWidth > 400){\n var bgOffset = (emoji * 200 * -1) + \"px 0px\"\n } else {\n var bgOffset = (emoji * 100 * -1) + \"px 0px\" \n }\n document.getElementById('emoji').style.backgroundPosition = bgOffset;\n }\n </script>\n</head>\n\n<body>\n\n <div class=\"four_oh_four\">\n <img class=\"logo\" src=\"/images/parse-logo.png\" width=\"98\" height=\"31\" />\n\n <figure class=\"error\">\n <h1>4<div id=\"emoji\"></div>4</h1>\n <h2>Oh no, we can’t find that page!</h2>\n </figure>\n\n <ul class=\"nav\">\n <li>Home\n </li>\n <li>Products\n </li>\n <li>Pricing\n </li>\n <li>Docs\n </li>\n <li>Help\n </li>\n <li>Blog\n </li>\n </ul>\n </div>\n\n</body>\n<script>\n catchFeelings();\n\n setTimeout(function () {\n setInterval(function () {\n catchFeelings()\n }, 3000)\n }, 3000)\n \n document.addEventListener('keydown', function(e) {\n e = e || window.event;\n switch (e.which || e.keyCode) {\n case 32:\n for (var i = 0; i < 20; i++) {\n setTimeout(function () {\n catchFeelings();\n }, 50 * i)\n }\n break;\n\n default:\n return;\n }\n e.preventDefault();\n });\n</script>\n\n</html>\n"
What's the wrong?
Thanks.
This issues has been resolved. % parse deploy again and it will update your cli. Run once again and it will succeed.
% parse deploy repos/parse-model NV-MBP
Downloading binary from https://parse.com/downloads/cloud_code/cli/parse-osx/latest.
Successfully updated binary at: /usr/local/bin/parse
% parse deploy repos/parse-model NV-MBP
JS SDK version not set, setting it to latest available JS SDK version
Uploading source files
Uploading recent changes to scripts...
The following files will be uploaded:
/cloud/main.js
Uploading recent changes to hosting...
The following files will be uploaded:
/public/index.html
Finished uploading files
New release is named v1 (using Parse JavaScript SDK v1.4.2)

How can I get Ruby's RestClient to use a multi-valued query parameter?

Using the RestClient gem, I need to create a request such as the following:
GET http://host/path?p=1&p=2
What is the proper syntax to accomplish this?
Note that the receiving host is not Rails.
Tried:
resource = RestClient::Resource.new( 'http://host/path' )
params = { p: '1', p: '2' }
# ^ Overrides param to have value of 2 (?p=2)
params = { p: ['1','2'] }
# ^ results in 'p[]=abc&p[]=cde' (array [] indicators not wanted)
resource.get( { params: params } )
You can pass the parameters in as a string:
resource.get(params: 'p=1&p=2')
For instance, using the restclient shell:
>> RestClient.log = Logger.new(STDOUT)
#<Logger:0x007fa444cbecc0 #progname=nil, #level=0, #default_formatter=#<Logger::Formatter:0x007fa444cbec70 #datetime_format=nil>, #formatter=nil, #logdev=#<Logger::LogDevice:0x007fa444cbebd0 #shift_size=nil, #shift_age=nil, #filename=nil, #dev=#<IO:<STDOUT>>, #mutex=#<Logger::LogDevice::LogDeviceMutex:0x007fa444cbeba8 #mon_owner=nil, #mon_count=0, #mon_mutex=#<Mutex:0x007fa444cbeb58>>>>
>> resource = RestClient::Resource.new( 'http://www.example.net' )
#<RestClient::Resource:0x007fa444c9fdc0 #url="http://www.example.net", #block=nil, #options={}>
>> resource.get(params: 'p=1&p=2')
RestClient.get "http://www.example.net", "Accept"=>"*/*; q=0.5, application/xml", "Accept-Encoding"=>"gzip, deflate", "Params"=>"p=1&p=2"
# => 200 OK | text/html 1270 bytes
"<!doctype html>\n<html>\n<head>\n <title>Example Domain</title>\n\n <meta charset=\"utf-8\" />\n <meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <style type=\"text/css\">\n body {\n background-color: #f0f0f2;\n margin: 0;\n padding: 0;\n font-family: \"Open Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n \n }\n div {\n width: 600px;\n margin: 5em auto;\n padding: 50px;\n background-color: #fff;\n border-radius: 1em;\n }\n a:link, a:visited {\n color: #38488f;\n text-decoration: none;\n }\n #media (max-width: 700px) {\n body {\n background-color: #fff;\n }\n div {\n width: auto;\n margin: 0 auto;\n border-radius: 0;\n padding: 1em;\n }\n }\n </style> \n</head>\n\n<body>\n<div>\n <h1>Example Domain</h1>\n <p>This domain is established to be used for illustrative examples in documents. You may use this\n domain in examples without prior coordination or asking for permission.</p>\n <p>More information...</p>\n</div>\n</body>\n</html>\n"
If you don't want to write code to build a string, which you should avoid because it's not necessarily straightforward, let Ruby's URI class cobble it together:
require 'uri'
URI::encode_www_form([['p', 1], ['p', 2]])
# => "p=1&p=2"
Discovered this issue for RestClient : https://github.com/rest-client/rest-client/issues/59
so it seems that it can't be done 'natively' through params.
My solution was to modify the URL, using:
query_params = "?p=1&p=2"
resource[query_params].get

Resources