从外部网站加载课程的表现

时间:2018-04-11 14:02:16

标签: javascript php jquery

我正在从外部网站加载div类.price的内容(数量/价格),以便我可以将它与我自己的价格进行比较。

我已经使用了这个有效,但确实降低了我的页面加载速度:

     DataTable dt = new DataTable();
     con.Open();
     SqlDataReader myReader;
     SqlCommand cmd = new SqlCommand("select First_name from Table_1 Where 
     Access = Access_withdraw order by Time", con);
     myReader = cmd.ExecuteReader();
     count = 0;

                    while (myReader.Read())
                    {
                        output[count] = myReader["First_name"].ToString();
                        count = count + 1;
                    }

                    Button1.Text = output[0]; 
                    Button2.Text = output[1];

这只是从外部网站加载的问题,还是有办法更快或更有效地加载内容?

我试过这个:

<?php 

$url = 'https://www.example.com/xxx/xxx/xxx';
$content = file_get_contents($url);
$first_step = explode( '<div class="price">' , $content );
$second_step = explode("</div>" , $first_step[1] );

echo $second_step[0];

?>  

是否需要为上述ID工作?或者javascript不能来自外部网站?

谢谢!

1 个答案:

答案 0 :(得分:0)

您可以做的是设置一个cron作业,从外部网站获取价格并将其存储在您的数据库中。根据价格变化的频率,您可以每天一次,每小时多次等等。

然后,您可以从自己的数据库中获取外部价格,并将其与您自己的价格进行比较,而无需连接到外部网站。

相关问题