I want to scrape dynamic data (refreshable every 4 seconds and it's a number ) with imacro and represent that number changing along the time in excell ( or any other way ).
How can i do this ? Imacro, as further as i know can get the data but can it scrap a dynamic one .
The code is from a basketball game on Flashscore ,exactly the scores table between 2 teams :
Here is an example for a game table
<table id="parts" class="parts-first horizontal">
<tbody>
<tr class="odd">
<td class="score"><span class="rb">69</span</td>
<td class="score part"><span class="p1_home">31</span></td>
</tr>
<tr class="even">
<td class="score"><span class="rb">63</span></td>
<td class="score part"><span class="p1_away">17</span></td>
</tr>
</tbody>
</table>
that gives those two lines data:
69
31
63
17
Here is the more detailed answer with a code.
TAG POS=1 TYPE=TD ATTR=CLASS:"score" EXTRACT=TXT
SET !EXTRACT EVAL("'{{!EXTRACT}}'.match(/\\d+/)[0];")
TAG POS=1 TYPE=TD ATTR=CLASS:"score part" EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=scores.csv
TAG POS=2 TYPE=TD ATTR=CLASS:"score" EXTRACT=TXT
SET !EXTRACT EVAL("'{{!EXTRACT}}'.match(/\\d+/)[0];")
TAG POS=2 TYPE=TD ATTR=CLASS:"score part" EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=scores.csv
WAIT SECONDS=4
Play this macro in loop mode (button ‘Play (Loop)’) with the max. number of loops equal to a very big integer (e.g. 99999).
Related
I have requirement,where i need to send file content as mail body.can we dot through unix scripting.
Thanks in Advance
With the data create a html file. And then send that file in email as content.
use an expression to create your file data like this -
v_data= ' <tr>
<td>'||company ||'</td>
<td>'|| contact_person|| '</td>
<td>'|| country ||'</td>
</tr>'
Use an aggregator to concat all these data into one single row. group by none.
Then use another expression transformation.
create a ports like this -
v_head ='
<head></head>
<body>
<b>pls find below data.</b>
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>'
v_body = Aggregated_v_data
v_tail='</table></body>'
v_output = v_head||v_body ||v_tail
Then use this output and connect to a flat file target.
Then send this flat file sing mailx command/any mail client.
Output should look like this.
html file should looks like this
<head></head>
<body>
pls find below data.
<br> </br>
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds </td>
<td>Maria </td>
<td>Germany</td>
</tr>
</table>
</body>
I have faced some of the issue page break in Qweb report in last few days.
I am trying to print my Qweb report for Cheque format and single Qweb page divided into 3 different sections
Section 1 : Displaying invoice list details
Section 2 : Bank details and amount which we will pay to our owner/tenant in MICR FONT 13B FONT
Section 3 : Displaying invoice list details
section 1 & 3 are the common and displaying the same invoices details into both of the sections and about the section2 will change as per the
different amount which we will pay to owner/tenant.
Expected Result :
I have 23 invoice details are attached it into single cheque then I want to bifurcate my invoice details into different slot
sloat 1 : Display first 10 invoice details into first page
sloat 2 : Display next 10 invoice details into second page
sloat 3 : Display remaning 3 invoice details into third page
I want to bifurcate my invoice details into different sloat wise page if the total number of invoices are more than 10 lines
What I have tried from my side ?
Attempt 1 : Using counter variable and update the counter through iterating the loop and break it when 10 is reach divide by 0
Applied this code inside into loping
<t t-set="count" t-value="count+1" />
<t t-if="count%10== 0">
<div style="page-break-after:auto;"/>
</t>
</t>
Attempt 2:
<span t-esc="line_index+1"/>
<t t-if="line_index+1%10 ==0">
<div style="page-break-inside:auto !important;">
</t>
I think you need to provide a little bit more of the context and info, perhaps the problem is other than that one are you exposing.
have you tried using a custom python report?
class IncrementReports(models.AbstractModel):
_name = 'report.your_model.your_report_name'
#api.model
def render_html(self, docids, data=None):
report_obj = self.env['report']
report = report_obj._get_report_from_name(
'your_model.your_report_name')
docs = []
objects = self.env[report.model].browse(docids)
for o in objects:
docs.append({...})
docargs = {
'doc_ids': docids,
'doc_model': report.model,
'docs': objects,
'custom_docs': docs,
'datetime': datetime.datetime,
}
return report_obj.render('your_model.your_report_name', docargs)
Using a custom report you can create a function to divide the 3 blocks of information, sending this in different variable inside de docargs and iterating over them without check the condition in the XML report.
I don't know if I'm clear, my English is not good enough.
I have also fixed the issue from my end after tried a lot more attempts.
If any one will face the same issue in your future development
so that they can also able to fix it quickly.
Create a method into specific model : (cheque.cheque model)
def get_invoice_details(self, invoice_ids,cheque):
vals,container,result,val=[],[],[],1
invoice_no=''
for line in invoice_ids:
desc=''
if line.is_vendor:
invoice_no=line.vendor_reference
else:
invoice_no=line.number
pay_amt=line.payment_ids.filtered(lambda m: m.cheque_issued_id.id ==cheque.id).amount or 0.00
for l in line.invoice_line_ids:
desc+=str(l.product_id.default_code)+',' or ''
vals.append({
'date':str(line.date_invoice),
'invoice_no':invoice_no,
'inv_amt':str(line.amount_total),
'description':desc,
'pay_amt':float(pay_amt)
})
invoice_no=''
for l in vals:
if val<=len(vals):
container.append(l)
if val % 9 == 0:
result.append({'section':9,'vals':container})
container=[]
val+=1
if container:
result.append({'section':4,'vals':container})
return result
In this method I have set section key with its value into result of list for dictionary
where we are using the same section to making the page break perfectly
Call the same method and iterate it into Qweb Template
<t t-foreach="o.get_invoice_details(o.invoice_ids,o)" t-as="line" >
<div class="page">
<div class="col-xs-12">
<table style="width:100%">
<thead>
<tr>
<th>Invoice Date</th>
<th>Invoice # </th>
<th>Invoice Amt</th>
<th>Description </th>
<th style="text-align:right">Payment Amt</th>
</tr>
</thead>
<t t-foreach="line.get('vals')" t-as="inv">
<tbody class="sale_tbody">
<tr>
<td>
<span t-esc="inv.get('date')" />
</td>
<td>
<span t-esc="inv.get('invoice_no')" />
</td>
<td>
<span t-esc="o.decimal_formated_amount(float(inv.get('inv_amt',0.00)))" />
</td>
<td>
<span t-esc="inv.get('description')" />
</td>
<td style="text-align:right">
<span t-esc="o.decimal_formated_amount2(float(inv.get('pay_amt',0.00)))" />
</td>
</tr>
</tbody>
</t>
</table>
</div>
<span t-if="line.get('section') % 9 == 0" style="page-break-after: always;">
</span>
</div>
As per the business logic of get_invoice_details() method
which is return the data in list form and then we can user the same and render it into the XML template.
Odoo will manage the page break automatically when the condition will satisfy over the XML template
system will automatically bifurcate the page according to source code
I hope my answer may helpful for you :)
I use a chain of
knitr::knit2html("test.Rmd") # generates test.md & test.html
rmarkdown::render("test.md") # overwrites test.html
to generate an html report.
This chain provides good functionality as my report usually combines pictures, tables & text. If I ran only
knitr::knit2html("test.Rmd")
"test.html" will be generated, but it looks awkward, i.e. pictures not shown correctly.
Normally, this works fine, but this time sample names that are headers of a table contain '+' or '-'.
| | IP_gene8-_1st| IP_gene8+_1st|
|:--------------|-------------:|-------------:|
|IP_gene8-_1st | 1.0000000| 0.4357325|
|IP_gene8+_1st | 0.4357325| 1.0000000|
"test.html" generated by knit2html("test.Rmd") will contain a valid table, but other pictures are not shown correctly.
<table><thead>
<tr>
<th align="left"></th>
<th align="right">IP_Rad18-_1st</th>
<th align="right">IP_Rad18_1st</th>
</tr>
</thead><tbody>
<tr>
<td align="left">IP_Rad18_1st</td>
<td align="right">1.0000000</td>
<td align="right">0.4357325</td>
</tr>
<tr>
<td align="left">IP_Rad18_1st</td>
<td align="right">0.4357325</td>
<td align="right">1.0000000</td>
</tr>
</tbody></table>
Running rmarkdown::render("test.md") produces a "test.html" with a table as text only, but e.g. pictures shown correctly. The crappy table output looks like this:
| | IP_gene8-_1st| IP_gene8+_1st|
|:-------------|-------------:|-------------:|
|IP_Rad18_1st | 1.0000000| 0.4357325|
|IP_Rad18_1st | 0.4357325| 1.0000000|
Usually, '+' and '-' can be protected using '/', but this does not have any effect in the table context.
Is there any way to trick rmarkdown::render() to create a valid html-table?
You can use below unicode entity code for +/- sign in markdown as well as html:
±
±
±
I want to export(force download) HTML(with CSS) to EXCEL sheet, for now I am using the PHPExcel library to perform this, it generate the excel file but remove the CSS (using inline with html tags), can anyone guide me, that how to keep CSS in excel sheet.
I am using this code, But I also want to keep the css and force to download
//html
$html = "<table>
<thead> <tr> <td colspan='2'> <h1> Main Heading </h1> <td> </tr> </thead>
<tbody>
<tr>
<th style='background:#ccc; color:red; font-size:15px'> Name <th>
<th style='background:#ccc; color:red; font-size:15px'> Class <th>
</tr>
<tr>
<td style='background:#fff; color:green; font-size:13px'> Jhon <th>
<td style='background:#fff; color:gree; font-size:13px'> 9th <th>
</tr>
</tbody>
</table>";
// Put the html into a temporary file
$tmpfile = time().'.html';
file_put_contents($tmpfile, $html);
// Read the contents of the file into PHPExcel Reader class
$reader = new PHPExcel_Reader_HTML;
$content = $reader->load($tmpfile);
// Pass to writer and output as needed
$objWriter = PHPExcel_IOFactory::createWriter($content, 'Excel2007');
$objWriter->save('excelfile.xlsx');
// Delete temporary file
unlink($tmpfile);
You can't read styles from HTML markup at the moment, unless you rewrite PHPExcel's HTML Reader to handle styles; it simply isn't supported yet. If you're building the spreadsheet from HTML, perhaps you should reconsider building it directly from a new PHPExcel object, which gives you access to all the features of PHPExcel.
To send to the browser, send to php://output with the appropriate headings, as shown in Examples/01simple-download-xlsx.php, and described in the section of the developer documentation entitled Redirect output to a client’s web browser
How can I use Chameleon or Zope Page Templates to easily create CSS zebra striping? I want to add odd and even classes to each row in a table, but using a condition with repeat/name/odd or repeat/name/even looks rather verbose even with a conditional expression:
<table>
<tr tal:repeat="row rows"
tal:attributes="class python:repeat['row'].odd and 'odd' or 'even'">
<td tal:repeat="col row" tal:content="col">column text text</td>
</tr>
</table>
This gets especially tedious if you have multiple classes to calculate.
The Zope Page Templates implementation for the repeat variable has an under-documented extra parameter, parity, than gives you the string 'odd' or 'even', alternating between iterations:
<table>
<tr tal:repeat="row rows"
tal:attributes="class repeat/row/parity">
<td tal:repeat="col row" tal:content="col">column text text</td>
</tr>
</table>
This is also much easier to interpolate into a string expression:
tal:attributes="class string:striped ${row/class} ${repeat/row/parity}"
This works in Chameleon as well.