![VFP 愛用者社區 首頁](templates/subSilver/images/vfps.jpg) |
VFP 愛用者社區 本討論區為 Visual Foxpro 愛用者經驗交流的地方, 請多多利用"搜尋"的功能, 先查看看有無前例可循, 如果還有不懂的再發問. 部份主題有附加檔案, 須先註冊成為社區居民才可以下載.
|
上一篇主題 :: 下一篇主題 |
發表人 |
內容 |
CPS0204
註冊時間: 2014-08-24 文章: 442
第 1 樓
|
|
回頂端 |
|
![](templates/subSilver/images/spacer.gif) |
Patrick Wu
註冊時間: 2007-01-03 文章: 223 來自: 台北市
第 2 樓
|
發表於: 星期三 二月 03, 2016 3:33 pm 文章主題: |
|
|
城市代號:TPE
城市英文:TAIPEI
國家英文:TAIWAN
城市中文:桃園國際機場
國家中文:台灣
格林威治:+8
是要這樣嗎 ???
如是 這是 後學 的強項 |
|
回頂端 |
|
![](templates/subSilver/images/spacer.gif) |
syntech
註冊時間: 2003-05-16 文章: 4215 來自: Taipei,Taiwan
第 3 樓
|
發表於: 星期三 二月 03, 2016 3:47 pm 文章主題: |
|
|
代碼: |
CREATE CURSOR CITYCODE (CITYCODE C(3),CITYNAME C(50),COUNTRY C(50),CITYNAME_E C(50),COUNTRY_E C(50),GMT I)
cPARA = "http://www.caneis.com.tw/home/information/citycode.htm "
DO 請大家幫幫我.PRG WITH cPARA
SELECT CITYCODE
BROWSE
|
_________________ 如果公司有下列困擾:
1. 找不到便宜,快速,簡易的 生產排程軟體
2. 不知道如何快速排定 採購計劃
3. 成本抓不準,自己算比軟體算有用
4. 想學習系統規劃,想找系統架構的顧問
請聯絡我們,也許我們幫得上忙 |
|
回頂端 |
|
![](templates/subSilver/images/spacer.gif) |
garfield Site Admin
![](images/avatars/1721266997466e2d116a266.jpg)
註冊時間: 2003-01-30 文章: 2158
第 4 樓
|
|
回頂端 |
|
![](templates/subSilver/images/spacer.gif) |
tuberose
註冊時間: 2006-05-02 文章: 33
第 5 樓
|
發表於: 星期四 二月 04, 2016 3:03 pm 文章主題: |
|
|
Clear
oIE = Createobject("internetexplorer.application")
oIE.Visible = .F.
oIE.Navigate("http://www.caneis.com.tw/home/information/citycode.htm")
tStartSecond = Seconds()
Do While oIE.Busy = .T. Or oIE.ReadyState#4
If Seconds() - tStartSecond > 10
Exit
Endif
=Inkey(0.5)
Enddo
Create Cursor 城市代碼 (中文城市名 C(20), 英文城市名 C(20), 代碼 C(4))
For I = 4 To 21
nTableNum = "oIE.Document.getElementsByTagName('table').[" + Alltrim(Str(I)) + "]"
objCollection = &nTableNum
objTable = objCollection
For Each objRow In objTable.Rows
If Type("objRow.cells(1).innertext") = "C" And ;
!Empty(Alltrim(objRow.cells(0).innertext)) ;
And objRow.cells(0).innertext <> "中文城市名稱" And ;
objRow.cells(0).innertext <> "城市名稱"
Insert Into 城市代碼 Values (objRow.cells(0).innertext, ;
objRow.cells(1).innertext, objRow.cells(2).innertext)
Endif
If Type("objRow.cells(5).innertext") = "C" And ;
!Empty(Alltrim(objRow.cells(4).innertext)) ;
And objRow.cells(4).innertext <> "中文城市名稱" And ;
objRow.cells(4).innertext <> "城市名稱"
Insert Into 城市代碼 Values (objRow.cells(4).innertext, ;
objRow.cells(5).innertext, objRow.cells(6).innertext)
Endif
Next
Endfor
Wait Window "完成." Timeout 1
oIE.Quit()
Go Top
Browse Last Title "城市代碼" |
|
回頂端 |
|
![](templates/subSilver/images/spacer.gif) |
CPS0204
註冊時間: 2014-08-24 文章: 442
第 6 樓
|
發表於: 星期四 二月 04, 2016 3:05 pm 文章主題: |
|
|
tuberose真是高手,謝謝
這就是我要的! |
|
回頂端 |
|
![](templates/subSilver/images/spacer.gif) |
tuberose
註冊時間: 2006-05-02 文章: 33
第 7 樓
|
發表於: 星期四 二月 04, 2016 3:19 pm 文章主題: |
|
|
Update :
oIE = Createobject("internetexplorer.application")
oIE.Visible = .F.
oIE.Navigate("http://www.caneis.com.tw/home/information/citycode.htm")
tStartSecond = Seconds()
Do While oIE.Busy = .T. Or oIE.ReadyState#4
If Seconds() - tStartSecond > 10
Exit
Endif
=Inkey(0.5)
Enddo
Create Cursor 城市代碼 (中文城市名 C(20), 英文城市名 C(20), 代碼 C(4))
For I = 4 To 21
nTableNum = "oIE.Document.getElementsByTagName('table').[" + Transform(I) + "]"
objTable = &nTableNum
For Each objRow In objTable.Rows
If Type("objRow.cells(1).innertext") = "C" And Len(Alltrim(objRow.cells(0).innertext)) > 3 ;
And objRow.cells(0).innertext <> "中文城市名稱" And objRow.cells(0).innertext <> "城市名稱"
Insert Into 城市代碼 Values (objRow.cells(0).innertext, objRow.cells(1).innertext, objRow.cells(2).innertext)
Endif
If Type("objRow.cells(5).innertext") = "C" And Len(Alltrim(objRow.cells(4).innertext)) > 3 ;
And objRow.cells(4).innertext <> "中文城市名稱" And objRow.cells(4).innertext <> "城市名稱"
Insert Into 城市代碼 Values (objRow.cells(4).innertext, objRow.cells(5).innertext, objRow.cells(6).innertext)
Endif
Next
Endfor
Wait Window "完成." Timeout 1
oIE.Quit()
Go Top
Browse Last Title "城市代碼" |
|
回頂端 |
|
![](templates/subSilver/images/spacer.gif) |
tuberose
註冊時間: 2006-05-02 文章: 33
第 8 樓
|
發表於: 星期四 二月 04, 2016 3:23 pm 文章主題: |
|
|
版本 2 : 文本方式
*!* Enumerates/Detect the number of tables and rows and columns and Cells in HTTP.
Clear
Set Safety Off
CRLF = Chr(13) + Chr(10)
cStr = ""
oIE = Createobject("internetexplorer.application")
oIE.Visible = .T.
oIE.Navigate("http://www.caneis.com.tw/home/information/citycode.htm") && Your Web
tStartSecond = Seconds()
Do While oIE.Busy = .T. Or oIE.ReadyState#4
If Seconds() - tStartSecond > 10
Exit
Endif
Inkey(0.5)
Enddo
*!* How many table(s) in the HTTP ?
cStr = "===================================" + CRLF
cStr = cStr + "A total number of tables : " + Alltrim(Str(oIE.Document.getElementsByTagName("Table").Length)) + CRLF
cStr = cStr + "===================================" + CRLF
*!* Enumerate each table.
For I = 0 To oIE.Document.getElementsByTagName("Table").Length - 1
nTableNum = "oIE.Document.getElementsByTagName('table').[" + Alltrim(Str(I)) + "]"
objCollection = &nTableNum
cStr = cStr + "Table : " + Alltrim(Str(I)) + CRLF
objTable = objCollection
nRow = objTable.Rows.Length && the number of Rows
nColumn = objTable.cells.Length/objTable.Rows.Length && the number of Columns
nCell = objTable.cells.Length && the number of Cells
cStr = cStr + "Rows number : " + Alltrim(Str(nRow)) + CRLF
cStr = cStr + "Columns number : " + Alltrim(Str(nColumn)) + CRLF
cStr = cStr + "Cells number : " + Alltrim(Str(nCell)) + CRLF
cStr = cStr + "..................." + CRLF
*!* Enumerate each cell in this table.
For Each objRow In objTable.Rows
For J = 0 To objTable.Rows.Length - 1
If Type("objRow.cells(J).innertext") = "C"
cStr = cStr + " " + Padr(objRow.cells(J).innertext, 24, ' ')
Endif
Endfor
cStr = cStr + CRLF
Next
cStr = cStr + CRLF + "===================================" + CRLF
Next
oIE.Quit()
=Strtofile(cStr, "MyDoc.txt")
Modify File MyDoc.txt |
|
回頂端 |
|
![](templates/subSilver/images/spacer.gif) |
CPS0204
註冊時間: 2014-08-24 文章: 442
第 9 樓
|
發表於: 星期五 三月 11, 2016 8:15 am 文章主題: |
|
|
謝謝!可以使用!
請幫忙再轉入dbf 一下(每天都要讀到的交叉匯率檔)
http://yamstock.megatime.com.tw/rate.htm
謝謝大大 |
|
回頂端 |
|
![](templates/subSilver/images/spacer.gif) |
tuberose
註冊時間: 2006-05-02 文章: 33
第 10 樓
|
發表於: 星期五 三月 11, 2016 10:02 am 文章主題: |
|
|
*!* Get Rate Date.
Clear
Wait Window "请稍等片刻......" Nowait
oIE = Createobject("Internetexplorer.Application")
oIE.Visible = .T. && Or .F.
oIE.Navigate("http://yamstock.megatime.com.tw/rate.htm") && Your Web
tStartSecond = Seconds()
Do While oIE.Busy = .T. Or oIE.ReadyState#4
If Seconds() - tStartSecond > 10 && Or 10+
Exit
Endif
Inkey(0.5)
Enddo
* Wait Wind "请稍等片刻......"
Create Cursor 交叉匯率表 ( 美金 C(6), 台幣 C(6), 日圓 C(6), ;
港幣 C(6), 人民幣 C(6), 英鎊 C(6), 歐元 C(6), 加幣 C(6), ;
澳幣 C(6), 泰銖 C(6), 紐幣 C(6), 南非幣 C(6) )
objTable = oIE.Document.getElementsByTagName("table").[2]
lnNum = 1
For Each objRow In objTable.Rows
If lnNum > 3
Insert Into 交叉匯率表 Values ( ;
Padl(objRow.cells(0).Innertext, 6, " " ), Padl(objRow.cells(1).Innertext, 6, " " ), ;
Padl(objRow.cells(2).Innertext, 6, " " ), Padl(objRow.cells(3).Innertext, 6, " " ), ;
Padl(objRow.cells(4).Innertext, 6, " " ), Padl(objRow.cells(5).Innertext, 6, " " ), ;
Padl(objRow.cells(6).Innertext, 6, " " ), Padl(objRow.cells(7).Innertext, 6, " " ), ;
Padl(objRow.cells( .Innertext, 6, " " ), Padl(objRow.cells(9).Innertext, 6, " " ), ;
Padl(objRow.cells(10).Innertext, 6, " " ), Padl(objRow.cells(11).Innertext, 6, " " ) )
Endif
lnNum = lnNum + 1
Next
oIE.Quit()
Wait Window "完成." Timeout 1
Browse Last Title "交叉匯率表" |
|
回頂端 |
|
![](templates/subSilver/images/spacer.gif) |
tuberose
註冊時間: 2006-05-02 文章: 33
第 11 樓
|
發表於: 星期五 三月 11, 2016 10:30 am 文章主題: |
|
|
Update :
*!* Get Rate Date.
Wait Window "请稍等片刻......" Nowait
oIE = Createobject("Internetexplorer.Application")
oIE.Visible = .T.
oIE.Navigate("http://yamstock.megatime.com.tw/rate.htm") && Your Web
tStartSecond = Seconds()
Do While oIE.Busy = .T. Or oIE.ReadyState#4
If Seconds() - tStartSecond > 10 && Or 10+
Exit
Endif
Inkey(0.5)
Enddo
* Wait Window "请稍等片刻......"
Create Cursor 交叉匯率表 ( 币种 C(6), 美金 C(6), 台幣 C(6), 圓 C(6), ;
日港幣 C(6), 人民幣 C(6), 英鎊 C(6), 歐元 C(6), 加幣 C(6), ;
澳幣 C(6), 泰銖 C(6), 紐幣 C(6), 南非幣 C(6) )
objTable = oIE.Document.getElementsByTagName("table").[2]
lnNum = 1
For Each objRow In objTable.Rows
If lnNum > 3
Insert Into 交叉匯率表 Values ( Padl(objRow.cells(0).Innertext, 6, " " ), ;
Padl(objRow.cells(1).Innertext, 6, " " ), Padl(objRow.cells(2).Innertext, 6, " " ), ;
Padl(objRow.cells(3).Innertext, 6, " " ), Padl(objRow.cells(4).Innertext, 6, " " ), ;
Padl(objRow.cells(5).Innertext, 6, " " ), Padl(objRow.cells(6).Innertext, 6, " " ), ;
Padl(objRow.cells(7).Innertext, 6, " " ), Padl(objRow.cells( .Innertext, 6, " " ), ;
Padl(objRow.cells(9).Innertext, 6, " " ), Padl(objRow.cells(10).Innertext, 6, " " ), ;
Padl(objRow.cells(11).Innertext, 6, " " ), Padl(objRow.cells(12).Innertext, 6, " " ) )
Endif
lnNum = lnNum + 1
Next
oIE.Quit()
Wait Window "完成." Timeout 1
Browse Last Title "交叉匯率表" |
|
回頂端 |
|
![](templates/subSilver/images/spacer.gif) |
215001
註冊時間: 2003-06-11 文章: 389
第 12 樓
|
發表於: 星期五 三月 11, 2016 11:10 am 文章主題: |
|
|
不錯的範例.先收藏起來
上面 日圓,日港幣 好像有問題,字放錯位置了 |
|
回頂端 |
|
![](templates/subSilver/images/spacer.gif) |
CPS0204
註冊時間: 2014-08-24 文章: 442
第 13 樓
|
發表於: 星期五 三月 11, 2016 11:49 am 文章主題: |
|
|
謝謝,高手真多 |
|
回頂端 |
|
![](templates/subSilver/images/spacer.gif) |
tuberose
註冊時間: 2006-05-02 文章: 33
第 14 樓
|
發表於: 星期五 三月 11, 2016 12:02 pm 文章主題: |
|
|
对不起,是我打错了,谢谢上面的网友的指正。
源代码:
Create Cursor 交叉匯率表 ( 币种 C(6), 美金 C(6), 台幣 C(6), 圓 C(6), ;
日港幣 C(6), 人民幣 C(6), 英鎊 C(6), 歐元 C(6), 加幣 C(6), ;
澳幣 C(6), 泰銖 C(6), 紐幣 C(6), 南非幣 C(6) )
改成:
Create Cursor 交叉匯率表 ( 币种 C(6), 美金 C(6), 台幣 C(6), 日圓 C(6), ;
港幣 C(6), 人民幣 C(6), 英鎊 C(6), 歐元 C(6), 加幣 C(6), ;
澳幣 C(6), 泰銖 C(6), 紐幣 C(6), 南非幣 C(6) ) |
|
回頂端 |
|
![](templates/subSilver/images/spacer.gif) |
|
|
您 無法 在這個版面發表文章 您 無法 在這個版面回覆文章 您 無法 在這個版面編輯文章 您 無法 在這個版面刪除文章 您 無法 在這個版面進行投票 您 無法 在這個版面附加檔案 您 無法 在這個版面下載檔案
|
|