MatPlus.Net

 Website founded by
Milan Velimirović
in 2006

22:55 UTC
ISC 2021
 
  Forum*
 
 
 

Username:

Password:

Remember me

 
Forgot your
password?
Click here!
SIGN IN
to create your account if you don't already have one.
CHESS
SOLVING

Tournaments
Rating lists
1-Oct-2021

B P C F





 
 
MatPlus.Net Forum General Getting the FEN string from a diagram in this forum.
 
You can only view this page!
(1) Posted by Rosie Fay [Thursday, Jul 15, 2021 15:20]

Getting the FEN string from a diagram in this forum.


Given a diagram in a message in a topic in this forum, how do I obtain the corresponding FEN string in plain text?

You can do this in Chess Stack Exchange (https://chess.stackexchange.com/questions) because this allows any user (with enough reputation points) to edit any message -- this gives the code from which a diagram was produced, and this code includes the FEN. Not that I intend to go around editing anybody else's messages, but how do I obtain the FEN for a diagram in MAT Plus?
 
(Read Only)pid=21364
(2) Posted by Dmitri Turevski [Thursday, Jul 15, 2021 16:55]

This works in Chrome: right-click the diagram and select "Copy image address". The copied address includes something very similar to the FEN string (only position part w/o slashes, also it apparently does some aritmetics: 88 becomes 16):
http://www.matplus.net/i.php?f=16pPR5pkPP1p2S1p2B2K7PP4P4B4
Not sure if it's really useable, though.
 
 
(Read Only)pid=21365
(3) Posted by Rosie Fay [Thursday, Jul 15, 2021 17:49]

Thank you! That really has helped. I already have a program which takes plain text input, including FEN strings, and turns it into Tex which, with the help of Ulrike Fischer's package "chessboard", produces a PDF with lovely diagrams which I can view using SumatraPDF. My program doesn't understand MAT Plus fen, but it must be possible to do that. So, usable after a bit of work.
 
   
(Read Only)pid=21366
(4) Posted by Hauke Reddmann [Thursday, Jul 15, 2021 20:55]

Firefox can do the same. My suggestion, since you have to
convert it anyway: A mini python proggie which grabs the
URL*, reads its source, scans for FEN images and
converts it to standard FEN. Would cost me half an hour
maximum to write working Python code for that...

* e.g. https://www.codegrepper.com/code-examples/python/how+to+get+source+code+of+website+in+python
("requests" is no standard package and must be pip-installed!
Windows-R, execute "pip install requests")

DEMO PROGRAM:
import requests

url = "http://matplus.net/start.php?px=1626375649&app=forum&act=posts&fid=gen&tid=2722&pid=21361#n21361";
#URL example - kill the semicolon, system inserted it!
html_output_name = "out.txt"

req = requests.get(url, "html.parser")

with open(html_output_name, "w", encoding="utf-8") as f:
f.write(req.text)
f.close()
piccode = "src='i.php?f=" # all FEN pics start thus
with open(html_output_name, "r", encoding="utf-8") as f:
lines = f.readlines()
for line in lines:
#c+=1
if piccode in line:
idx=line.find("small")
print(line[42:idx-3]replace("%2F","/"))
f.close()


Output - all FENs of the images in the URL
6b1/8/8/2n2k2/8/3PP3/1p3P2/1B1K4
7Q/N7/4K3/8/n5q1/8/5R2/2k5
8/1BK5/7r/8/8/8/2RNR3/3k4
k7/1pP5/1P6/8/8/1K3rPR/1PPPPP2/8
r6k/2R4P/8/8/8/1P2PP2/6Bp/2K3S1
1K1s3B/r6q/pR6/k1pS1R2/p1P4r/P1S4B/Q7/8
kB5K/2P4B/P4rP1/4r3/2S1s3/1RP4S/3b4/6RQ
k7/1R6/P4K2/P7/P7/P5r1/8/7R
1N6/pq3P2/p2p4/P3k1B1/2RNp1r1/P1P1P3/2P1p1rp/4R2K

Untested if all images work this way!
 
 
(Read Only)pid=21367

No more posts


MatPlus.Net Forum General Getting the FEN string from a diagram in this forum.