How to use Height method of html Package

Best K6 code snippet using html.Height

conversion.go

Source:conversion.go Github

copy

Full Screen

1package html2import (3 "net/http"4 "strconv"5 "gitlab.com/aspose-cloud-go/aspose-cloud-common-go"6 "gitlab.com/aspose-cloud-go/aspose-cloud-rest-go"7)8// ConversionAPI represents a collection of functions to interact with the Conversion REST API endpoints9// (see https://apireference.aspose.cloud/html/#!/Conversion).10type ConversionAPI common.BaseAPI11// NewConversionAPI returns new initialized ConversionAPI structure.12func NewConversionAPI(baseURL, token string) (*ConversionAPI, error) {13 api, err := common.NewBaseAPI(baseURL, token)14 if err != nil {15 return nil, err16 }17 return (*ConversionAPI)(api), nil18}19// GetConvertDocumentToImage converts the HTML document (located on storage) to the specified image format20// and returns resulting file in response content.21func (api *ConversionAPI) GetConvertDocumentToImage(name, outFormat string,22 width, height, leftMargin, rightMargin, topMargin, bottomMargin, resolution *int,23 folder, storage string) ([]byte, error) {24 // https://apireference.aspose.cloud/html/#!/Conversion/Conversion_GetConvertDocumentToImage25 if !common.ValidArg(name) {26 return nil, common.ErrEmptyName27 }28 if !common.ValidArg(outFormat) {29 return nil, common.ErrIsEmpty("outFormat")30 }31 u := *api.BaseURL32 // /html/{name}/convert/image/{outFormat}33 u.Path = common.PathJoin(u.Path, _html, name, _convert, _image, outFormat)34 q := u.Query()35 if width != nil {36 q.Set(_width, strconv.Itoa(*width))37 }38 if height != nil {39 q.Set(_height, strconv.Itoa(*height))40 }41 if leftMargin != nil {42 q.Set(_leftMargin, strconv.Itoa(*leftMargin))43 }44 if rightMargin != nil {45 q.Set(_rightMargin, strconv.Itoa(*rightMargin))46 }47 if topMargin != nil {48 q.Set(_topMargin, strconv.Itoa(*topMargin))49 }50 if bottomMargin != nil {51 q.Set(_bottomMargin, strconv.Itoa(*bottomMargin))52 }53 if resolution != nil {54 q.Set(_resolution, strconv.Itoa(*resolution))55 }56 if len(storage) > 0 {57 q.Set(common.Storage, storage)58 }59 if len(folder) > 0 {60 q.Set(common.Folder, folder)61 }62 u.RawQuery = q.Encode()63 return rest.BytesFromURL(u.String(), http.MethodGet, api.Token, "", nil)64}65// PutConvertDocumentToImage converts the HTML document (located on storage) to the specified image format66// and uploads resulting file to storage.67func (api *ConversionAPI) PutConvertDocumentToImage(name, outPath, outFormat string,68 width, height, leftMargin, rightMargin, topMargin, bottomMargin, resolution *int,69 folder, storage string) error {70 // https://apireference.aspose.cloud/html/#!/Conversion/Conversion_PutConvertDocumentToImage71 if !common.ValidArg(name) {72 return common.ErrEmptyName73 }74 if !common.ValidArg(outPath) {75 return common.ErrIsEmpty("outPath")76 }77 if !common.ValidArg(outFormat) {78 return common.ErrIsEmpty("outFormat")79 }80 u := *api.BaseURL81 // /html/{name}/convert/image/{outFormat}82 u.Path = common.PathJoin(u.Path, _html, name, _convert, _image, outFormat)83 q := u.Query()84 q.Set(_outPath, outPath)85 if width != nil {86 q.Set(_width, strconv.Itoa(*width))87 }88 if height != nil {89 q.Set(_height, strconv.Itoa(*height))90 }91 if leftMargin != nil {92 q.Set(_leftMargin, strconv.Itoa(*leftMargin))93 }94 if rightMargin != nil {95 q.Set(_rightMargin, strconv.Itoa(*rightMargin))96 }97 if topMargin != nil {98 q.Set(_topMargin, strconv.Itoa(*topMargin))99 }100 if bottomMargin != nil {101 q.Set(_bottomMargin, strconv.Itoa(*bottomMargin))102 }103 if resolution != nil {104 q.Set(_resolution, strconv.Itoa(*resolution))105 }106 if len(storage) > 0 {107 q.Set(common.Storage, storage)108 }109 if len(folder) > 0 {110 q.Set(common.Folder, folder)111 }112 u.RawQuery = q.Encode()113 return rest.ErrFromURL(u.String(), http.MethodPut, api.Token, "", nil)114}115// GetConvertDocumentToPdf converts the HTML document (located on storage) to PDF116// and returns resulting file in response content.117func (api *ConversionAPI) GetConvertDocumentToPdf(name string,118 width, height, leftMargin, rightMargin, topMargin, bottomMargin *int,119 folder, storage string) ([]byte, error) {120 // https://apireference.aspose.cloud/html/#!/Conversion/Conversion_GetConvertDocumentToPdf121 if !common.ValidArg(name) {122 return nil, common.ErrEmptyName123 }124 u := *api.BaseURL125 // /html/{name}/convert/pdf126 u.Path = common.PathJoin(u.Path, _html, name, _convert, _pdf)127 q := u.Query()128 if width != nil {129 q.Set(_width, strconv.Itoa(*width))130 }131 if height != nil {132 q.Set(_height, strconv.Itoa(*height))133 }134 if leftMargin != nil {135 q.Set(_leftMargin, strconv.Itoa(*leftMargin))136 }137 if rightMargin != nil {138 q.Set(_rightMargin, strconv.Itoa(*rightMargin))139 }140 if topMargin != nil {141 q.Set(_topMargin, strconv.Itoa(*topMargin))142 }143 if bottomMargin != nil {144 q.Set(_bottomMargin, strconv.Itoa(*bottomMargin))145 }146 if len(storage) > 0 {147 q.Set(common.Storage, storage)148 }149 if len(folder) > 0 {150 q.Set(common.Folder, folder)151 }152 u.RawQuery = q.Encode()153 return rest.BytesFromURL(u.String(), http.MethodGet, api.Token, "", nil)154}155// PutConvertDocumentToPdf converts the HTML document (located on storage) to PDF156// and uploads resulting file to storage.157func (api *ConversionAPI) PutConvertDocumentToPdf(name, outPath string,158 width, height, leftMargin, rightMargin, topMargin, bottomMargin *int,159 folder, storage string) error {160 // https://apireference.aspose.cloud/html/#!/Conversion/Conversion_PutConvertDocumentToPdf161 if !common.ValidArg(name) {162 return common.ErrEmptyName163 }164 if !common.ValidArg(outPath) {165 return common.ErrIsEmpty("outPath")166 }167 u := *api.BaseURL168 // /html/{name}/convert/pdf169 u.Path = common.PathJoin(u.Path, _html, name, _convert, _pdf)170 q := u.Query()171 q.Set(_outPath, outPath)172 if width != nil {173 q.Set(_width, strconv.Itoa(*width))174 }175 if height != nil {176 q.Set(_height, strconv.Itoa(*height))177 }178 if leftMargin != nil {179 q.Set(_leftMargin, strconv.Itoa(*leftMargin))180 }181 if rightMargin != nil {182 q.Set(_rightMargin, strconv.Itoa(*rightMargin))183 }184 if topMargin != nil {185 q.Set(_topMargin, strconv.Itoa(*topMargin))186 }187 if bottomMargin != nil {188 q.Set(_bottomMargin, strconv.Itoa(*bottomMargin))189 }190 if len(storage) > 0 {191 q.Set(common.Storage, storage)192 }193 if len(folder) > 0 {194 q.Set(common.Folder, folder)195 }196 u.RawQuery = q.Encode()197 return rest.ErrFromURL(u.String(), http.MethodPut, api.Token, "", nil)198}199// GetConvertDocumentToXps converts the HTML document (located on storage) to XPS200// and returns resulting file in response content.201func (api *ConversionAPI) GetConvertDocumentToXps(name string,202 width, height, leftMargin, rightMargin, topMargin, bottomMargin *int,203 folder, storage string) ([]byte, error) {204 // https://apireference.aspose.cloud/html/#!/Conversion/Conversion_GetConvertDocumentToXps205 if !common.ValidArg(name) {206 return nil, common.ErrEmptyName207 }208 u := *api.BaseURL209 // /html/{name}/convert/xps210 u.Path = common.PathJoin(u.Path, _html, name, _convert, _xps)211 q := u.Query()212 if width != nil {213 q.Set(_width, strconv.Itoa(*width))214 }215 if height != nil {216 q.Set(_height, strconv.Itoa(*height))217 }218 if leftMargin != nil {219 q.Set(_leftMargin, strconv.Itoa(*leftMargin))220 }221 if rightMargin != nil {222 q.Set(_rightMargin, strconv.Itoa(*rightMargin))223 }224 if topMargin != nil {225 q.Set(_topMargin, strconv.Itoa(*topMargin))226 }227 if bottomMargin != nil {228 q.Set(_bottomMargin, strconv.Itoa(*bottomMargin))229 }230 if len(storage) > 0 {231 q.Set(common.Storage, storage)232 }233 if len(folder) > 0 {234 q.Set(common.Folder, folder)235 }236 u.RawQuery = q.Encode()237 return rest.BytesFromURL(u.String(), http.MethodGet, api.Token, "", nil)238}239// PutConvertDocumentToXps converts the HTML document (located on storage) to XPS240// and uploads resulting file to storage.241func (api *ConversionAPI) PutConvertDocumentToXps(name, outPath string,242 width, height, leftMargin, rightMargin, topMargin, bottomMargin *int,243 folder, storage string) error {244 // https://apireference.aspose.cloud/html/#!/Conversion/Conversion_PutConvertDocumentToXps245 if !common.ValidArg(name) {246 return common.ErrEmptyName247 }248 if !common.ValidArg(outPath) {249 return common.ErrIsEmpty("outPath")250 }251 u := *api.BaseURL252 // /html/{name}/convert/xps253 u.Path = common.PathJoin(u.Path, _html, name, _convert, _xps)254 q := u.Query()255 q.Set(_outPath, outPath)256 if width != nil {257 q.Set(_width, strconv.Itoa(*width))258 }259 if height != nil {260 q.Set(_height, strconv.Itoa(*height))261 }262 if leftMargin != nil {263 q.Set(_leftMargin, strconv.Itoa(*leftMargin))264 }265 if rightMargin != nil {266 q.Set(_rightMargin, strconv.Itoa(*rightMargin))267 }268 if topMargin != nil {269 q.Set(_topMargin, strconv.Itoa(*topMargin))270 }271 if bottomMargin != nil {272 q.Set(_bottomMargin, strconv.Itoa(*bottomMargin))273 }274 if len(storage) > 0 {275 q.Set(common.Storage, storage)276 }277 if len(folder) > 0 {278 q.Set(common.Folder, folder)279 }280 u.RawQuery = q.Encode()281 return rest.ErrFromURL(u.String(), http.MethodPut, api.Token, "", nil)282}283// GetConvertDocumentToImageByUrl converts the HTML page (located in the Web) to the specified image format284// and returns resulting file in response content.285func (api *ConversionAPI) GetConvertDocumentToImageByUrl(sourceUrl, outFormat string,286 width, height, leftMargin, rightMargin, topMargin, bottomMargin, resolution *int) ([]byte, error) {287 // https://apireference.aspose.cloud/html/#!/Conversion/Conversion_GetConvertDocumentToImageByUrl288 if !common.ValidArg(sourceUrl) {289 return nil, common.ErrIsEmpty("sourceUrl")290 }291 if !common.ValidArg(outFormat) {292 return nil, common.ErrIsEmpty("outFormat")293 }294 u := *api.BaseURL295 // /html/convert/image/{outFormat}296 u.Path = common.PathJoin(u.Path, _html, _convert, _image, outFormat)297 q := u.Query()298 q.Set(_sourceURL, sourceUrl)299 if width != nil {300 q.Set(_width, strconv.Itoa(*width))301 }302 if height != nil {303 q.Set(_height, strconv.Itoa(*height))304 }305 if leftMargin != nil {306 q.Set(_leftMargin, strconv.Itoa(*leftMargin))307 }308 if rightMargin != nil {309 q.Set(_rightMargin, strconv.Itoa(*rightMargin))310 }311 if topMargin != nil {312 q.Set(_topMargin, strconv.Itoa(*topMargin))313 }314 if bottomMargin != nil {315 q.Set(_bottomMargin, strconv.Itoa(*bottomMargin))316 }317 if resolution != nil {318 q.Set(_resolution, strconv.Itoa(*resolution))319 }320 u.RawQuery = q.Encode()321 return rest.BytesFromURL(u.String(), http.MethodGet, api.Token, "", nil)322}323// PutConvertDocumentInRequestToImage converts the HTML document (in request content) to the specified image format324// and uploads resulting file to storage.325func (api *ConversionAPI) PutConvertDocumentInRequestToImage(outPath, outFormat string,326 width, height, leftMargin, rightMargin, topMargin, bottomMargin, resolution *int,327 file string) error {328 // https://apireference.aspose.cloud/html/#!/Conversion/Conversion_PutConvertDocumentInRequestToImage329 if !common.ValidArg(outPath) {330 return common.ErrIsEmpty("outPath")331 }332 if !common.ValidArg(outFormat) {333 return common.ErrIsEmpty("outFormat")334 }335 body, err := common.CheckOpenBody(file)336 // body will be eventually closed by http.DefaultClient.Do()337 if err != nil {338 return err339 }340 u := *api.BaseURL341 // /html/convert/image/{outFormat}342 u.Path = common.PathJoin(u.Path, _html, _convert, _image, outFormat)343 q := u.Query()344 q.Set(_outPath, outPath)345 if width != nil {346 q.Set(_width, strconv.Itoa(*width))347 }348 if height != nil {349 q.Set(_height, strconv.Itoa(*height))350 }351 if leftMargin != nil {352 q.Set(_leftMargin, strconv.Itoa(*leftMargin))353 }354 if rightMargin != nil {355 q.Set(_rightMargin, strconv.Itoa(*rightMargin))356 }357 if topMargin != nil {358 q.Set(_topMargin, strconv.Itoa(*topMargin))359 }360 if bottomMargin != nil {361 q.Set(_bottomMargin, strconv.Itoa(*bottomMargin))362 }363 if resolution != nil {364 q.Set(_resolution, strconv.Itoa(*resolution))365 }366 u.RawQuery = q.Encode()367 return rest.ErrFromURL(u.String(), http.MethodPut, api.Token, "", body)368}369// GetConvertDocumentToPdfByUrl converts the HTML page from the web by its URL to PDF.370func (api *ConversionAPI) GetConvertDocumentToPdfByUrl(sourceUrl string,371 width, height, leftMargin, rightMargin, topMargin, bottomMargin *int) ([]byte, error) {372 // https://apireference.aspose.cloud/html/#!/Conversion/Conversion_GetConvertDocumentToPdfByUrl373 if !common.ValidArg(sourceUrl) {374 return nil, common.ErrIsEmpty("sourceUrl")375 }376 u := *api.BaseURL377 // /html/convert/pdf378 u.Path = common.PathJoin(u.Path, _html, _convert, _pdf)379 q := u.Query()380 q.Set(_sourceURL, sourceUrl)381 if width != nil {382 q.Set(_width, strconv.Itoa(*width))383 }384 if height != nil {385 q.Set(_height, strconv.Itoa(*height))386 }387 if leftMargin != nil {388 q.Set(_leftMargin, strconv.Itoa(*leftMargin))389 }390 if rightMargin != nil {391 q.Set(_rightMargin, strconv.Itoa(*rightMargin))392 }393 if topMargin != nil {394 q.Set(_topMargin, strconv.Itoa(*topMargin))395 }396 if bottomMargin != nil {397 q.Set(_bottomMargin, strconv.Itoa(*bottomMargin))398 }399 u.RawQuery = q.Encode()400 return rest.BytesFromURL(u.String(), http.MethodGet, api.Token, "", nil)401}402// PutConvertDocumentInRequestToPdf converts the HTML document (in request content) to PDF403// and uploads resulting file to storage.404func (api *ConversionAPI) PutConvertDocumentInRequestToPdf(outPath string,405 width, height, leftMargin, rightMargin, topMargin, bottomMargin *int,406 file string) error {407 // https://apireference.aspose.cloud/html/#!/Conversion/Conversion_PutConvertDocumentInRequestToPdf408 if !common.ValidArg(outPath) {409 return common.ErrIsEmpty("outPath")410 }411 body, err := common.CheckOpenBody(file)412 // body will be eventually closed by http.DefaultClient.Do()413 if err != nil {414 return err415 }416 u := *api.BaseURL417 // /html/convert/pdf418 u.Path = common.PathJoin(u.Path, _html, _convert, _pdf)419 q := u.Query()420 q.Set(_outPath, outPath)421 if width != nil {422 q.Set(_width, strconv.Itoa(*width))423 }424 if height != nil {425 q.Set(_height, strconv.Itoa(*height))426 }427 if leftMargin != nil {428 q.Set(_leftMargin, strconv.Itoa(*leftMargin))429 }430 if rightMargin != nil {431 q.Set(_rightMargin, strconv.Itoa(*rightMargin))432 }433 if topMargin != nil {434 q.Set(_topMargin, strconv.Itoa(*topMargin))435 }436 if bottomMargin != nil {437 q.Set(_bottomMargin, strconv.Itoa(*bottomMargin))438 }439 u.RawQuery = q.Encode()440 return rest.ErrFromURL(u.String(), http.MethodPut, api.Token, "", body)441}442// GetConvertDocumentToXpsByUrl converts the HTML page from the web by its URL to XPS.443func (api *ConversionAPI) GetConvertDocumentToXpsByUrl(sourceUrl string,444 width, height, leftMargin, rightMargin, topMargin, bottomMargin *int) ([]byte, error) {445 // https://apireference.aspose.cloud/html/#!/Conversion/Conversion_GetConvertDocumentToXpsByUrl446 if !common.ValidArg(sourceUrl) {447 return nil, common.ErrIsEmpty("sourceUrl")448 }449 u := *api.BaseURL450 // /html/convert/xps451 u.Path = common.PathJoin(u.Path, _html, _convert, _xps)452 q := u.Query()453 q.Set(_sourceURL, sourceUrl)454 if width != nil {455 q.Set(_width, strconv.Itoa(*width))456 }457 if height != nil {458 q.Set(_height, strconv.Itoa(*height))459 }460 if leftMargin != nil {461 q.Set(_leftMargin, strconv.Itoa(*leftMargin))462 }463 if rightMargin != nil {464 q.Set(_rightMargin, strconv.Itoa(*rightMargin))465 }466 if topMargin != nil {467 q.Set(_topMargin, strconv.Itoa(*topMargin))468 }469 if bottomMargin != nil {470 q.Set(_bottomMargin, strconv.Itoa(*bottomMargin))471 }472 u.RawQuery = q.Encode()473 return rest.BytesFromURL(u.String(), http.MethodGet, api.Token, "", nil)474}475// PutConvertDocumentInRequestToXps converts the HTML document (in request content) to XPS476// and uploads resulting file to storage.477func (api *ConversionAPI) PutConvertDocumentInRequestToXps(outPath string,478 width, height, leftMargin, rightMargin, topMargin, bottomMargin *int,479 file string) error {480 // https://apireference.aspose.cloud/html/#!/Conversion/Conversion_PutConvertDocumentInRequestToXps481 if !common.ValidArg(outPath) {482 return common.ErrIsEmpty("outPath")483 }484 body, err := common.CheckOpenBody(file)485 // body will be eventually closed by http.DefaultClient.Do()486 if err != nil {487 return err488 }489 u := *api.BaseURL490 // /html/convert/xps491 u.Path = common.PathJoin(u.Path, _html, _convert, _xps)492 q := u.Query()493 q.Set(_outPath, outPath)494 if width != nil {495 q.Set(_width, strconv.Itoa(*width))496 }497 if height != nil {498 q.Set(_height, strconv.Itoa(*height))499 }500 if leftMargin != nil {501 q.Set(_leftMargin, strconv.Itoa(*leftMargin))502 }503 if rightMargin != nil {504 q.Set(_rightMargin, strconv.Itoa(*rightMargin))505 }506 if topMargin != nil {507 q.Set(_topMargin, strconv.Itoa(*topMargin))508 }509 if bottomMargin != nil {510 q.Set(_bottomMargin, strconv.Itoa(*bottomMargin))511 }512 u.RawQuery = q.Encode()513 return rest.ErrFromURL(u.String(), http.MethodPut, api.Token, "", body)514}...

Full Screen

Full Screen

renderer.go

Source:renderer.go Github

copy

Full Screen

1package main2import (3 "fmt"4 "strings"5)6// RenderHeader 页头7func RenderHeader(header string) string {8 return `<p style="white-space: normal;"><span style="font-size: 15px; color: rgb(255, 255, 255); background-color: rgb(72, 91, 247); padding: 5px;"><strong>` + header + `</strong></span></p>`9}10// RenderFooter 页尾11func RenderFooter(footer string) string {12 return `<p style="white-space: normal; text-align: right;"><span style="font-size: 15px; color: rgb(255, 255, 255); background-color: rgb(72, 91, 247); padding: 5px;"><strong>` + footer + `</strong></span></p>`13}14// RenderTitle 主标题15func RenderTitle(title string) string {16 return `<p style="text-align: center; padding-right: 16px; padding-left: 16px; margin-bottom: 10px;"><span style="color: rgb(72, 91, 247); font-size: 24px; letter-spacing: 0.5px; line-height: 1.75em;"><strong>` + title + `</strong></span></p>`17}18// RenderSubtitle 子标题19func RenderSubtitle(subtitle string) string {20 return `<p style="text-align: center; padding-right: 16px; padding-left: 16px; margin-bottom: 10px;"><span style="color: rgb(72, 91, 247); font-size: 17px; letter-spacing: 0.5px; line-height: 1.75em;"><strong>` + subtitle + `</strong></span></p>`21}22// RenderPlaceholder 占位符23func RenderPlaceholder() string {24 return `<p style="text-align: center;"><br></p>`25}26// RenderContent 内容27func RenderContent(contents []string) string {28 html := `<p style="height: 10px; min-height: 0px;"></p>`29 for i, content := range contents {30 html += `<p style="padding-right: 10px; padding-left: 10px;"><span style="font-size: 15px; letter-spacing: 0.5px; line-height: 1.75em; white-space: normal;">` + content + `</span></p>`31 if i < len(contents)-1 {32 html += `<p style="text-align: center;"><br></p>`33 }34 }35 return html36}37// RenderStockTable 股票表格38func RenderStockTable(stocks []Stock) string {39 html := `<table style="width: 100%; padding-right: 16px; padding-left: 16px; border: 0px; line-height: 0;"><tbody>`40 for i := 0; i < len(stocks); i++ {41 var percentColor string42 if stocks[i].Percent == "0.00%" {43 percentColor = "color: rgb(153, 153, 153);"44 } else if strings.Contains(stocks[i].Percent, "+") {45 percentColor = "color: rgb(246, 66, 69);"46 } else {47 percentColor = "color: rgb(0, 171, 59);"48 }49 var currentYearPercentColor string50 if stocks[i].CurrentYearPercent == "0.00%" {51 currentYearPercentColor = "color: rgb(153, 153, 153);"52 } else if strings.Contains(stocks[i].CurrentYearPercent, "+") {53 currentYearPercentColor = "color: rgb(246, 66, 69);"54 } else {55 currentYearPercentColor = "color: rgb(0, 171, 59);"56 }57 html += `<tr style="border: 0px;">`58 html += `<td style="width: 30%; border: 0px; border-bottom: 0px dashed #ccc; padding-top: 10px; padding-bottom: 10px;"><span style="font-size: 15px; letter-spacing: 0.5px; line-height: 1.25em;">` + stocks[i].Name + `</span><br/><span style="font-size: 12px; letter-spacing: 0.5px; line-height: 1.25em; color: #888;">` + stocks[i].Code + `</span></td>`59 html += `<td style="width: 25%; border: 0px; border-bottom: 0px dashed #ccc; padding-top: 10px; padding-bottom: 10px; text-align: right;"><span style="font-size: 15px; letter-spacing: 0.5px; line-height: 1.75em;">` + stocks[i].Value + `</span></td>`60 html += `<td style="width: 45%; border: 0px; border-bottom: 0px dashed #ccc; padding-top: 10px; padding-bottom: 10px; text-align: right;"><span style="font-size: 15px; letter-spacing: 0.5px; line-height: 1.25em; ` + percentColor + `">` + stocks[i].Current + `</span><span style="font-size: 15px; letter-spacing: 0.5px; line-height: 1.25em; ` + percentColor + `"> ` + stocks[i].Percent + `</span><br/><span style="font-size: 12px; letter-spacing: 0.5px; line-height: 1.25em; ` + currentYearPercentColor + `">` + stocks[i].CurrentYearPercent + `</span></td>`61 html += `</tr>`62 }63 html += `</tbody></table>`64 return html65}66// RenderStockChart 股票柱状图67func RenderStockChart(bars []Bar) string {68 html := `<table style="width: 100%; padding-right: 16px; padding-left: 16px; border: 0px; line-height: 0;"><tbody>`69 html += `<tr style="border: 0px;">`70 for i := 0; i < len(bars); i++ {71 var color, backgroundColor string72 if bars[i].Flag == 1 {73 color = "color: rgb(246, 66, 69);"74 backgroundColor = "background-color: rgb(246, 66, 69);"75 } else if bars[i].Flag == 0 {76 color = "color: rgb(153, 153, 153);"77 backgroundColor = "background-color: rgb(153, 153, 153);"78 } else {79 color = "color: rgb(0, 171, 59);"80 backgroundColor = "background-color: rgb(0, 171, 59);"81 }82 html += `<td valign="bottom" style="border: 0px; text-align: center;"><span style="font-size: 12px; letter-spacing: 0.5px; line-height: 1.75em; ` + color + `">` + Float64ToString(bars[i].Value) + `</span><br/><span style="display: inline-block; border-radius: 5px 5px 0 0; width: 100%; height: ` + fmt.Sprintf("%.2f", 200*bars[i].Ratio) + "px; " + backgroundColor + `"></span><br/><span style="font-size: 12px; letter-spacing: 0.5px; line-height: 1.75em;">` + bars[i].Name + `</span></td>`83 }84 html += `</tr>`85 html += `</tbody></table>`86 return html87}88// RenderStockThermometer 股票温度计89func RenderStockThermometer(bars []Bar) string {90 html := `<table style="width: 100%; padding-right: 16px; padding-left: 16px; border: 0px; line-height: 0;"><tbody>`91 html += `<tr style="border: 0px;">`92 var down, flat, up float6493 for i := 0; i < len(bars); i++ {94 if bars[i].Flag == 1 {95 up += bars[i].Value96 } else if bars[i].Flag == 0 {97 flat += bars[i].Value98 } else {99 down += bars[i].Value100 }101 }102 html += `<td valign="top" style="width: ` + fmt.Sprintf("%.2f", down/(down+flat+up)*100) + `%-25px; border: 0px; text-align: center; padding-left: 8px; padding-right: 0px; padding-top: 12px;"><span style="display: inline-block; border-radius: 5px 0 0 5px; width: 100%; height: 5px; background-color: rgb(0, 171, 59);"></span><br/><span style="font-size: 12px; letter-spacing: 0.5px; line-height: 1.75em; color: rgb(0, 171, 59);">` + Float64ToString(down) + `</span></td>`103 html += `<td valign="top" style="width: ` + fmt.Sprintf("%.2f", flat/(down+flat+up)*100) + `%; border: 0px; text-align: center; padding-left: 0px; padding-right: 0px; padding-top: 12px;"><span style="display: inline-block; width: 100%; height: 5px; background-color: rgb(153, 153, 153);"></span><br/><span style="font-size: 12px; letter-spacing: 0.5px; line-height: 1.75em; color: rgb(153, 153, 153); display: none;">` + Float64ToString(flat) + `</span></td>`104 html += `<td valign="top" style="width: ` + fmt.Sprintf("%.2f", up/(down+flat+up)*100) + `%-25px; border: 0px; text-align: center; padding-left: 0px; padding-right: 0px; padding-top: 12px;"><span style="display: inline-block; border-radius: 0 5px 5px 0; width: 100%; height: 5px; background-color: rgb(246, 66, 69);"></span><br/><span style="font-size: 12px; letter-spacing: 0.5px; line-height: 1.75em; color: rgb(246, 66, 69);">` + Float64ToString(up) + `</span></td>`105 html += `<td valign="top" style="width: 50px; border: 0px; text-align: center; padding-left: 0px; padding-right: 0px;"><span style="font-size: 12px; letter-spacing: 0.5px; line-height: 1.75em; color: rgb(246, 66, 69);">` + fmt.Sprintf("%.0f", (up/(up+flat+down))*100) + "℃" + `</span></td>`106 html += `</tr>`107 html += `</tbody></table>`108 return html109}110// RenderStockTimeline 股票时间线111func RenderStockTimeline(events []Event) string {112 html := `<table style="width: 100%; padding-right: 16px; padding-left: 16px; border: 0px; line-height: 0;"><tbody>`113 for i := 0; i < len(events); i++ {114 html += `<tr style="border: 0px;">`115 html += `<td valign="top" style="width: 70px; border: 0px; border-bottom: 0px dashed #ccc; padding-top: 10px; padding-bottom: 10px;"><span style="font-size: 15px; letter-spacing: 0.5px; line-height: 1.75em;"><strong>` + events[i].Time + `</strong></span></td>`116 html += `<td valign="top" style="border: 0px; border-bottom: 0px dashed #ccc; padding-top: 10px; padding-bottom: 10px;"><span style="font-size: 15px; letter-spacing: 0.5px; line-height: 1.75em;">` + events[i].Content + `</span></td>`117 html += `</tr>`118 }119 html += `</tbody></table>`120 return html121}122// RenderStockPlate 股票板块图123func RenderStockPlate(stocks []Stock) string {124 html := `<table style="width: 100%; padding-right: 2px; padding-left: 2px; border: 0px; line-height: 0; border-collapse: separate; border-spacing: 5px 5px;"><tbody>`125 for i := 0; i < len(stocks); i++ {126 var backgroundColor string127 if stocks[i].Percent == "0.00%" {128 backgroundColor = "background-color: rgb(153, 153, 153);"129 } else if strings.Contains(stocks[i].Percent, "+") {130 backgroundColor = "background-color: rgb(246, 66, 69);"131 } else {132 backgroundColor = "background-color: rgb(0, 171, 59);"133 }134 if i%3 == 0 {135 html += `<tr style="border: 0px;">`136 }137 var borderRadius string138 if i == 0 {139 borderRadius = "border-radius: 10px 0 0 0;"140 } else if i == 2 {141 borderRadius = "border-radius: 0 10px 0 0;"142 } else if i == len(stocks)-1 {143 borderRadius = "border-radius: 0 0 10px 0;"144 } else if i == len(stocks)-3 {145 borderRadius = "border-radius: 0 0 0 10px;"146 }147 html += `<td style="width: 33.33%; height: 50px; border: 0px; border-bottom: 0px dashed #ccc; text-align: center; ` + backgroundColor + " " + borderRadius + `"><span style="font-size: 15px; letter-spacing: 0.5px; line-height: 1.25em; color: #fff;">` + stocks[i].Name + `</span><br/><span style="font-size: 12px; letter-spacing: 0.5px; line-height: 1.25em; color: #fff;">` + stocks[i].Percent + `</span></td>`148 if (i+1)%3 == 0 {149 html += `</tr>`150 }151 }152 html += `</tbody></table>`153 return html154}155// RenderStockCard 股票卡片图156func RenderStockCard(stocks []Stock) string {157 html := `<table style="width: 100%; padding-right: 2px; padding-left: 2px; border: 0px; line-height: 0; border-collapse: separate; border-spacing: 5px 5px;"><tbody>`158 for i := 0; i < len(stocks); i++ {159 var backgroundColor string160 if strings.Index(stocks[i].Value, "0.00") == 0 {161 backgroundColor = "background-color: rgb(153, 153, 153);"162 } else if strings.Contains(stocks[i].Value, "+") {163 backgroundColor = "background-color: rgb(246, 66, 69);"164 } else {165 backgroundColor = "background-color: rgb(0, 171, 59);"166 }167 if i%2 == 0 {168 html += `<tr style="border: 0px;">`169 }170 html += `<td style="width: 50%; height: 50px; border: 0px; border-bottom: 0px dashed #ccc; text-align: center; border-radius: 10px;` + backgroundColor + `"><span style="font-size: 15px; letter-spacing: 0.5px; line-height: 1.25em; color: #fff;">` + stocks[i].Name + `</span><br/><span style="font-size: 12px; letter-spacing: 0.5px; line-height: 1.25em; color: #fff;">` + stocks[i].Value + `</span></td>`171 if (i+1)%2 == 0 {172 html += `</tr>`173 }174 }175 html += `</tbody></table>`176 return html177}...

Full Screen

Full Screen

NodeClient.go

Source:NodeClient.go Github

copy

Full Screen

...76 requestBody := JsonUtil.ToString(request)77 responseHtml := NetUtil.Get(requestUrl, requestBody)78 return JsonUtil.ToObject(responseHtml, dto.PostBlockResponse{}).(*dto.PostBlockResponse)79}80func (n *NodeClient) PostBlockchainHeight(request dto.PostBlockchainHeightRequest) *dto.PostBlockchainHeightResponse {81 defer func() {82 if e := recover(); e != nil {83 LogUtil.Error("client error.", e)84 }85 }()86 requestUrl := n.getUrl(API.POST_BLOCKCHAIN_HEIGHT)87 requestBody := JsonUtil.ToString(request)88 responseHtml := NetUtil.Get(requestUrl, requestBody)89 return JsonUtil.ToObject(responseHtml, dto.PostBlockchainHeightResponse{}).(*dto.PostBlockchainHeightResponse)90}91func (n *NodeClient) GetBlockchainHeight(request dto.GetBlockchainHeightRequest) *dto.GetBlockchainHeightResponse {92 defer func() {93 if e := recover(); e != nil {94 LogUtil.Error("client error.", e)95 }96 }()97 requestUrl := n.getUrl(API.GET_BLOCKCHAIN_HEIGHT)98 requestBody := JsonUtil.ToString(request)99 responseHtml := NetUtil.Get(requestUrl, requestBody)100 return JsonUtil.ToObject(responseHtml, dto.GetBlockchainHeightResponse{}).(*dto.GetBlockchainHeightResponse)101}102func (n *NodeClient) GetUnconfirmedTransactions(request dto.GetUnconfirmedTransactionsRequest) *dto.GetUnconfirmedTransactionsResponse {103 defer func() {104 if e := recover(); e != nil {105 LogUtil.Error("client error.", e)106 }107 }()108 requestUrl := n.getUrl(API.GET_UNCONFIRMED_TRANSACTIONS)109 requestBody := JsonUtil.ToString(request)110 responseHtml := NetUtil.Get(requestUrl, requestBody)111 return JsonUtil.ToObject(responseHtml, dto.GetUnconfirmedTransactionsResponse{}).(*dto.GetUnconfirmedTransactionsResponse)112}113func (n *NodeClient) getUrl(api string) string {114 return "http://" + n.ip + ":" + StringUtil.ValueOfUint64(NetworkSetting.PORT) + api...

Full Screen

Full Screen

Height

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 doc, err := html.Parse(os.Stdin)4 if err != nil {5 fmt.Fprintf(os.Stderr, "findlinks1: %v6 os.Exit(1)7 }8 fmt.Println(Height(doc))9}10func Height(n *html.Node) int {11 if n == nil {12 }13 for c := n.FirstChild; c != nil; c = c.NextSibling {14 h = max(h, Height(c))15 }16}17func max(x, y int) int {18 if x > y {19 }20}21import (22func main() {23 doc, err := html.Parse(os.Stdin)24 if err != nil {25 fmt.Fprintf(os.Stderr, "findlinks1: %v26 os.Exit(1)27 }28 fmt.Println(doc.Depth())29}30import (31func main() {32 doc, err := html.Parse(os.Stdin)33 if err != nil {34 fmt.Fprintf(os.Stderr, "findlinks1: %v35 os.Exit(1)36 }37 fmt.Println(doc.Depth())38}39import (40func main() {41 doc, err := html.Parse(os.Stdin)42 if err != nil {43 fmt.Fprintf(os.Stderr, "findlinks1: %v44 os.Exit(1)45 }46 fmt.Println(doc.Depth())47}48import (49func main() {50 doc, err := html.Parse(os.Stdin)51 if err != nil {

Full Screen

Full Screen

Height

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 doc, err := html.Parse(os.Stdin)4 if err != nil {5 fmt.Fprintf(os.Stderr, "findlinks1: %v6 os.Exit(1)7 }8 fmt.Println(Height(doc))9}10func Height(n *html.Node) int {11 if n == nil {12 }13 return 1 + max(Height(n.FirstChild), Height(n.NextSibling))14}15func max(a, b int) int {16 if a > b {17 }18}19func ElementByID(doc *html.Node, id string) *html.Node20import (21func main() {22 doc, err := html.Parse(os.Stdin)23 if err != nil {24 fmt.Fprintf(os.Stderr, "findlinks1: %v25 os.Exit(1)26 }27 fmt.Println(ElementByID(doc, "test"))28}29func ElementByID(n *html.Node, id string) *html.Node {30 if n.Type == html.ElementNode {31 for _, a := range n.Attr {32 if a.Key == "id" && a.Val == id {33 }34 }35 }36 for c := n.FirstChild; c != nil; c = c.NextSibling {37 if ElementByID(c, id) != nil {38 }39 }40}41&{1 [id=test] <nil> <nil> <nil>}

Full Screen

Full Screen

Height

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 doc, err := html.Parse(strings.NewReader(`<html><head></head><body></body></html>`))4 if err != nil {5 fmt.Println(err)6 }7 fmt.Println(doc.FirstChild.LastChild.LastChild.FirstChild.Data)8}

Full Screen

Full Screen

Height

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 doc, err := html.Parse(strings.NewReader("<html><body><h1>Hi</h1></body></html>"))4 if err != nil {5 fmt.Println(err)6 }7 fmt.Println(doc.FirstChild.FirstChild.FirstChild.Data)8}

Full Screen

Full Screen

Height

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 doc, err := html.Parse(strings.NewReader("<html><body><p>Hello World</p></body></html>"))4 if err != nil {5 fmt.Println(err)6 }7 fmt.Println(doc.FirstChild.FirstChild.FirstChild.FirstChild.Data)8}9Related Posts: GoLang | html.Parse() Method

Full Screen

Full Screen

Height

Using AI Code Generation

copy

Full Screen

1import ( "fmt"2func main() {3 doc, err := html.Parse(strings.NewReader("<html><body><h1>Heading</h1></body></html>"))4 if err != nil {5 fmt.Println(err)6 }7 fmt.Println(doc.FirstChild.FirstChild.FirstChild.Data)8 fmt.Println(doc.FirstChild.FirstChild.FirstChild.FirstChild.Data)9 fmt.Println(doc.FirstChild.FirstChild.FirstChild.FirstChild.FirstChild.Data)10}

Full Screen

Full Screen

Height

Using AI Code Generation

copy

Full Screen

1import "fmt"2import "github.com/PuerkitoBio/goquery"3func main() {4if err != nil {5fmt.Println(err)6}7height := doc.Find("html").Height()8fmt.Println(height)9}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run K6 automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful